When I say just started, I mean yesterday. I'm using this to teach myself.I'm understanding the basics, but it gives you a few practice problems after introducing a new element. I just got through the chapter on loops. The practice problem I'm stuck on is:I can't figure out return the sum after accepting the input with loops.
i wanna get me some books 2 soon.but i dont understand what it askin by a running sum of inputs from users? like#include <string>int main() {string input;while(true){cin >> input >> endl;if(cin == "0"){system("pause")return exit_success;}}}lol maybe i just dumb and dont understand.
#Swag <stankleg>int snapbacksIf(snapback = yes)grant tattoosreturn exit_style
I code in swag motherforgeterssss!Code: [Select]#Swag <stankleg>int snapbacksIf(snapback = yes)grant tattosreturn exit_style
#Swag <stankleg>int snapbacksIf(snapback = yes)grant tattosreturn exit_style
#Swag <stankleg>NUMS snapbacksIf(snapback = yes)grant tattosreturn exit_style
It means the user types in a number, and it will spit out that number, then the user enters another number, and it will be that number plus the previous number, and repeat.For example, I type 5 and it returns 5, then I type 7 and it returns 12, then I type 4 and it returns 16. But if I type 0, the program terminates.
why is op talking like a handicap? its not even like less effort was put into his posts, he actually makes more of an effort to sound like he doesnt know basic english.
int a = 0;int b = 0;while(true){ a = input; if(a=0){ terminate; } print(a+b); b = a + b; //need this to remember old val}
Here's my psuedo:
int main (){int total = 0;int input = 0;bool quit = false;while ( quit == false ){cin >> input;total = total + input;if ( input == 0 )quit = true;cout << total << endl;}return 0;}
So messy, a loop should be broken by satisfying the while condition.Code: [Select]int main (){int total = 0;int input = 0;bool quit = false;while ( quit == false ){cin >> input >> endl;total = total + input;if ( input == 0 )quit = true;cout << total << endl;}return 0;}
int main (){int total = 0;int input = 0;bool quit = false;while ( quit == false ){cin >> input >> endl;total = total + input;if ( input == 0 )quit = true;cout << total << endl;}return 0;}