Thursday, July 30, 2009

What is the code in C programming that after i 10 numbers i could get their average?

What is the code in C programming that after i 10 numbers i could get their average?


I really need the syntax or the code in C programming that after i enter ten (10) numbers, then i can get their average. Please help me. Thank you so much. Godbless!!

What is the code in C programming that after i 10 numbers i could get their average?
I'm not going to do your homework for you, but the general structure of your program should look like this:


----------------------


Declare the array 'input'


Declare the number 'total'


Repeat 10 times:


-----Read in a number from the keyboard into the array 'input'


Set 'total' equal to '0'


Repeat for i=1 to 10:


-----Add 'input' array element 'i' to 'total'


Divide 'total' by 10


Print out 'total'


----------------------


The syntax for all of those lines should be in your text book, or is easy to find on the internet.








___________________


Hope that helps, Adam


My online games website: http://www.cygnetgames.co.uk
Reply:Try this, it has syntax and operators





http://www.cs.duke.edu/csed/tapestry/how...
Reply:#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;


main()


{


clrscr();


int sum=0, num,avg;


printf("Enter 10 numbers");


for(i=0;i%26lt;=10;i++)


{


scanf("%d",%26amp;num);


sum=sum+num;


}


avg=sum/10;


printf("Average =%d\n",sum,avg);


getch();


}


No comments:

Post a Comment