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 |
Write a c-programe that input one number of four digits and find digits sum?
Find the error (2.5*2=5) (a) X=y=z=0.5,2.0-5.75 (b) s=15;
Display this kind of output on screen. 1 0 1 1 0 1 3. Display this kind of output on screen. 1 1 0 1 0 1 4. Display this kind of output on screen. 1 1 0 1 0 1 5.Display this kind of output on screen. 1 2 3 4 5 6 7 8 9 10
What is probability to guarantee that the task a programmer is going to create will be created and be able to run on a particular system (RTOS/GPOS).
WHAT WILL BE THE OUTPUT OF THE FOLLOWING QUESTION void main() { int x=4,y=3,z; z=x-- -y; printf("%d%d%d",x,y,z); }
what is meant by linking error? how can i solve it? if there is a linking error " unable to open file 'cos.obj'? then what should i do?
what is syntax error?
class test { int a; public: test(int b):a(b){} void show(){ cout<<a; } }; void main() { test t1; test t2(5); t1.show(); t2.show(); } }
write the value of x and y after execution of the statements: int x=19,y; y=x++ + ++x; x++; y++;
wap for bubble sort
who was the present cheif governor of reserve bank of india
6 Answers State Bank Of India SBI,
How to develop a program using C language to convert 8-bit binary values to decimals. TQ