Given that two int variables, total and amount, have been
declared, write a loop that reads integers into amount and
adds all the non-negative values into total. The loop
terminates when a value less than 0 is read into amount.
Don't forget to initialize total to 0.
Instructor's notes: This problem requires either a while or
a do-while loop.
Answers were Sorted based on User's Feedback
Answer / helen
total=0;
cin>>amount;
while (amount>=0)
{
total=total+amount;
cin>>amount;
}
Is This Answer Correct ? | 43 Yes | 20 No |
Answer / cammy pope
total=0;
cin>>amount;
total= total+amount;
cin>>amount;
total= total+amount;
cin>>amount;
total= total+amount;
Is This Answer Correct ? | 10 Yes | 13 No |
Answer / abhishek rajput
int total=0, amount;
scanf("%d",&amount);
while(amount>0)
{
total=total+amount;
scanf("%d",&amount);
}
printf("total=%d",total);
Is This Answer Correct ? | 1 Yes | 5 No |
A sample program using data structure? what is file handling?
who was the present cheif governor of reserve bank of india
6 Answers State Bank Of India SBI,
how to convert decimal to hexadecimal without using arrays just loops
void main() { int i=5; printf("%d",i+++++i); }
Assume that the int variables i and j have been declared, and that n has been declared and initialized. Write code that causes a "triangle" of asterisks of size n to be output to the screen. Specifically, n lines should be printed out, the first consisting of a single asterisk, the second consisting of two asterisks, the third consistings of three, etc. The last line should consist of n asterisks. Thus, for example, if n has value 3, the output of your code should be * ** *** You should not output any space characters. Hint: Use a for loop nested inside another for loop.
Why are memory errors hard to debug?
which typw of errors ? & how to solve it ?
char* f() return "hello:"; void main() {char *str=f(); }
I am using Qt 5.6 during compilation it stops and gives error about Qmake The process "C:QtQt5.6.35.6.3msvc2015_64inqmake.exe" crashed. Error while building/deploying project untitled1 (kit: Desktop Qt 5.6.3 MSVC2015 64bit) When executing step "qmake"
what is meant for variable not found?
when i use cout or cin call & then either << or >> .....it shows declaration syntax error...what should i do? cout<<"anything"; int a; cin>>a; return 0;
How to create a program that lists the capital country when told what the original country is? (Terribly sorry, I'm a novice programmer and would appreciate any help ;). Cheers, Alexxis