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 |
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
Given an int variable n that has been initialized to a positive value and, in addition, int variables k and total that have already been declared, use a do...while loop to compute the sum of the cubes of the first n whole numbers, and store this value in total . Thus if n equals 4, your code should put 1*1*1 + 2*2*2 + 3*3*3 + 4*4*4 into total . Use no variables other than n , k , and total .
what is exceptions?
What is the out put of this programme? int a,b,c,d; printf("Enter Number!\n"); scanf("%d",&a); while(a=!0) { printf("Enter numbers/n"); scanf("%d%d%d",&b,&c,&d); a=a*b*c*d; } printf("thanks!"); getche(); Entering numbers are a=1,b=2,c=3,d=4 b=3,c=4,d=-5 b=3,c=4,d=0
Using string functions write a program that will accept the name of the capital as input value and will display the corresponding country. ------------------------ Capitals Countries ------------------------ Capitals Countries Ottawa Canada Moscow Russia Rome Italy I can't not get it to run properly
errors are known as?
3 Answers EX, State Bank Of India SBI,
wap for bubble sort
To generate the series 1+3+5+7+... using C program
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?
Answering Yes or No in C++...using only stdio.h and conio.h..........help me please...? here's must be the output of the program: Screen A Exam No. items Score 1 20 20 2 35 35 Another Entry? [Y] or [N] : Screen B: Record No. Student's Name: 1 Fernando Torres 2 Chuck Norris Note: if you press Y, the program must repeat the procedure in screen A, then if N, the program must proceed to the screen B....Please Help me out............
I'm having trouble with coming up with the correct code. Thank You!! The assignment was to write a program using string functions that accepts a price of an item and displays its coded value. The base of the keys: X C O M P U T E R S 0 1 2 3 4 5 6 7 8 9 Sample I/O Dialogue: Enter Price: 489.50 Coded Value: PRS.UX
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.