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
Why shouldn't Matrix class's interface look like an array-of-array? A: Some people build a Matrix class that has an operator[] that returns a reference to an Array object (or po

Pebble Merchant Problem Description There is a pebble merchant. He sells the pebbles, that are used for shining the floor. His main duty is to take the length of the room’s sides


You are working for a computer gaming company and have been asked to look at a survival game.  You will be simulating a rabbit stranded on an island, collecting a large number of s

one of the segments is showing compilation error...

The program will consist of two text fields, two buttons, and a counter label.  One text field will be input, where the user types the plain text.  The second text field will be ou

minimum of seven number


Create a class  called  ticketSelling that stores booking information of a single performance on a single day and sells the tickets of the performance. The class should include at