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
how to define the structures

Explain about Evaluation of Expression in c language? An Expressions are evaluated using an assignment statement of the form: variable = expression; The Variable is any v


Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

Hi, I want to get rtsp source for windows

complex coding with structure and file handling

#questionhow can i add new customer and alot him a new unique id ..

Develop libcurl XML project I have a Project using XML with C++. You will use things like LIbcurl etc....and a XML parser to finish the project. Developer must know how to use X

Public derivation Public derivations are much more common than private derivations. In this situation: The private members inherited from the base class are inaccessible

For this assignment, I've provided a data file called 'elevation.mat', which contains the elevation data you'll be working with.   Type load elevation.mat to get the varia