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?
UINT i,j; i = j = 0; i = ( i++ > ++j ) ? i++ : i--; explain pls....
which typw of errors ? & how to solve it ?
main() { char c; for(c='A';c<='Z';c++) getch(); }
Given an int variable n that has already been declared and initialized to a positive value, and another int variable j that has already been declared, use a do...while loop to print a single line consisting of n asterisks. Thus if n contains 5, five asterisks will be printed. Use no variables other than n and j .
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.
How to create a program that lists countries capitals when country is entered? (Terribly sorry, I'm a complete novist to coding with C, am looking for inspiration and general tips on how to code and create this program.)
I'm having trouble with coming up with the correct code. Do I need to put a loop? Please let me know if I'm on the right track and what areas I need to correct. I still don't have a good grasp on this programming stuff. Thanks =) The assignment was to write a program using string functions that accepts a coded value of an item and displays its equivalent tag price. The base of the keys: 0 1 2 3 4 5 6 7 8 9 X C O M P U T E R S Sample I/O Dialogue: Enter coded value: TR.XX Tag Price : 68.00
void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?..
32 Answers College School Exams Tests, CTS, HCL, iGate, SmartData,
Find the error (2.5*2=5) (a) X=y=z=0.5,2.0-5.75 (b) s=15;
wap for bubble sort
what is the error in the following code: main() { int i=400,j; j=(i*i)/i; }