question about while loop and for loop.

Write your question here.
here i have question and i really dont know to do.. confusing.

write a complete code that will fill while loop and for loop num with 20 values of type int read on from the keyboard.Display the sum and average for these 20 values. The output shall be as follows:

Enter 20 number:

Number 1:12
Number 2:5
Number 3:6
-
-
Number 20:7

The sum of 20 numbers : 220
The average of 20 Number : 11.00

Please note, that this is not a homework site. We won't do your homework for you. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.

We didn't see your attempts to solve this problem youself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again. As it is impossible to find deriviative of function without knowledge in ariphmetics, you cannot do more complex tasks in programming without clear understanding of basics.
https://www.youtube.com/playlist?list=PLAE85DE8440AA6B83

Great tutorials there. Look up the videos on for loop and while loop. Also watch pretty much everything else, it really helps :)
hmm thank you guys.. =) hope it wil help me. =)
guys i meet one more help.. i done my coding lit bit. now i want to know how to do repeatation in my coding after press yes or no.. please teach me how to do repeatation


1
2
3
4
5
std::string yn;
do
{
    //...
}while((std::cout << "Do you want to start over? (y/n): ") && (std::cin >> yn) && yn == "y");
Last edited on
sorry ... =( my lecturer nvr teach string :( issit C languege ?
i did like this..

char answer;
do
{
cout<< "Do you want to continue (Y/N)?\n";
cin >> answer;
}
while((answer !='Y')&&(answer !='N')&&(answer !='y')&&(answer !='n'));
Why do you care if the user enters anything other than 'Y'? You give them a clear message that they have to enter 'Y' in order to repeat, it is their fault if they ignore the message.

std::string is part of C++ and should be one of the first things you are taught. If you are being taught C instead of C++, you should indicate that in your first post; you are on a C++ forum, and the default assumption is that you want C++ help.
Topic archived. No new replies allowed.