Ask your own question, for FREE!
Computer Science 18 Online
OpenStudy (anonymous):

make and run a program that will display the average of scores entered by a user using FUNCTIONS in a Dev C++ application. The program should ask how many times the user will enter scores. sample output: how many scores? 5 85 76 84 90 86 the average score is 84.2

OpenStudy (anonymous):

int x ; double result; cout <<"Enter The number : "; cin >> x; result = calc (x); cout << "The result is " << result; //The function : double calc (int num){ int temp , result; for (int i=0; i<num ; i++){ cin>>temp; result +=temp; } return temp/num; }

OpenStudy (anonymous):

sorry .... return result/num; :) P:

OpenStudy (anonymous):

int temp , result; for (int i=0; i<num ; i++){ cin>>temp; result +=temp; } --is it really a temp? what is temp?

OpenStudy (anonymous):

do you mean why did I choose this variable name ? because we need it temporarily , It's a temporary variable helps us to calculate the result I mean when we go out the "for" loop we don't use it .... so it's temporary anyway You could choose the name you like :)

OpenStudy (anonymous):

ah ..ok ..i got it :) thanks for the info.

OpenStudy (anonymous):

You're welcome at any time :)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!