C program for function of average, C/C++ Programming

Assignment Help:

C program for function  of average

int average(int);

void main()

{

          int max=0,c=0;

          clrscr();

          printf("ENTER THE LIMIT OF INPUT FOR AVERAGE: ");

          scanf("%d",&max);

          c=average(max);

          printf("THE AVERAGE OF %d DIGIT IS %d",max,c);

          getch();

}

int average(int i)

{

          int j=0,n=0,sum=0;

          for(j=1;j<=i;j++)

          {

                   printf("ENTER THE DIGIT: ");

 

                   scanf("%d",&n);

                   sum=sum+n;

          }

          sum=sum/i;

          return(sum);

}

 

OUTPUT :

ENTER THE LIMIT OF INPUT FOR AVG : 5

ENTER THE DIGIT: 5

ENTER THE DIGIT : 10

ENTER THE DIGIT : 15

ENTER THE DIGIT : 20

ENTER THE DIGIT : 10

THE AVERAGE OF 5 DIGIT IS 12

 


Related Discussions:- C program for function of average

Tree, Ask question #M i want to undersatnd about tree structures like node ...

Ask question #M i want to undersatnd about tree structures like node leaf etcinimum 100 words accepted#

Prob, Given an integer n and a permutation of numbers 1, 2 ... , n-1, n wri...

Given an integer n and a permutation of numbers 1, 2 ... , n-1, n write a program to print the permutation that lexicographically precedes the given input permutation. If the given

Creating shopping carts, how to create a shopping cart and sibmit the code ...

how to create a shopping cart and sibmit the code segment on screan

Destructor on a local variable, Should I explicitly call a destructor on a ...

Should I explicitly call a destructor on a local variable? Explain it.

C programs, accept principal amount,rate of interest, & duration from the u...

accept principal amount,rate of interest, & duration from the user. display interest amount and total amount

Name the operators which cannot be overloaded?, Q: Name the operators which...

Q: Name the operators which cannot be overloaded? A:sizeof, ., .*, .->, ::, ?:

System programing, #quesdifferentiate betweenrelocatable and self relocatin...

#quesdifferentiate betweenrelocatable and self relocating program with exampletion..

Function that has two int parameters number , Write a function that has two...

Write a function that has two int parameters num and n, and returns TRUE when the nth bit in num is 1, otherwise FALSE. This function should use the function in the above problem.

Basic Programming Constructs, Write a program to print all the factors of a...

Write a program to print all the factors of a positive integer A

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd