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

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

 

Posted Date: 9/10/2012 8:05:46 AM | Location : United States







Related Discussions:- C program for function of average, Assignment Help, Ask Question on C program for function of average, Get Answer, Expert's Help, C program for function of average Discussions

Write discussion on C program for function of average
Your posts are moderated
Related Questions
I am seeking an expert to create a 360 degree virtual tour in KRPano for use on PCs, tablets and smartphones. You will be given with panoramas in order to create an advanced KRPano

Define External Static Storage Class - Computer Programming? An external static is declared outside of all the functions and is obtainable to all functions in that program. The

(Random Numbers) Write statements that assign random integers to the variable n in the following ranges: a) 1 ≤ n ≤2 b) 1 ≤ n ≤100 c) 0 ≤ n ≤9 d) 1000 ≤ n ≤1112 e)

to design a car that travels along the room and gives the length of the room

To complete this assignment, edit the following constructors and methods: 1. public MaxPQ(Key[] keys) - change the following loop for (int k = N/2; k >= 1; k--) sink(k);

Webcam Driver static library or DLL required for Windows I want a .dll or .lib file using which i will take a snapshot from the webcam and it can't turn on the webcam LED while

Q: however shouldn't I always use a printOn() method instead of a friend function? A: No. The usual cause people wish to always use a printOn() method instead of  a friend fu

Literals (Constants) Constants are data storage locations whose address is not accessible for the user. Their value is not altered during the course of the program. Literal

a padovan string p(n) for a natural number n is defined as p(0)=''x'' p(1)=''y'' p(2)=''z'' p(n)=p(n-2)+p(n-3),n>2

Ask question # Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particu