Given that two int variables, total and amount , have
been declared, write a sequence of statements that:
initializes total to 0
reads three values into amount , one at a time.

After each value is read in to amount , it is added to the
value in total (that is, total is incremented by the value
in amount ).


Instructor's notes: If you use a loop, it must be a for loop.
And if you use a loop control variable for counting, you
must declare it.



Given that two int variables, total and amount , have been declared, write a sequence of stateme..

Answer / raj

total= 0;

scanf("%d",&amount);
total +=amount;
scanf("%d",&amount);
total +=amount;
scanf("%d",&amount);
total +=amount;

Is This Answer Correct ?    29 Yes 16 No

Post New Answer

More C C++ Errors Interview Questions

Find the error (2.5*2=5) (a) X=y=z=0.5,2.0-5.75 (b) s=15;

3 Answers  


what is meant for variable not found?

3 Answers  


I can not get my C++ program to work right. It is supposed to tell if a word is a palindrome or not, but it only tells thet the word is not a palindrome. And I can't fix it.

1 Answers  


full c programming error question based problem

3 Answers   HCL, TCS,


void main() { int i=5,y=3,z=2,ans; clrscr(); printf("%d",++i + --z + i++ + --i * ++y); i=5,y=3,z=2; ans=++i + --z + i++ + --i * ++y; printf("\n%d",ans); getch(); } Its output is 37 and 31.... Please explain me why its different How it works.....

2 Answers  






difference between c/c++ programing language? what is necessesity of c++ when existing c programing language?

2 Answers   TCS,


UINT i,j; i = j = 0; i = ( i++ > ++j ) ? i++ : i--; explain pls....

5 Answers  


char* f() return "hello:"; void main() {char *str=f(); }

1 Answers  


what is macro in c? Difference between single linked list & double linked list what is fifo & lifo? what is stack & queue?

2 Answers   TCS,


What are the different types of errors in C and when they occur?

4 Answers  


Given that two int variables, total and amount , have been declared, write a sequence of statements that: initializes total to 0 reads three values into amount , one at a time. After each value is read in to amount , it is added to the value in total (that is, total is incremented by the value in amount ). Instructor's notes: If you use a loop, it must be a for loop. And if you use a loop control variable for counting, you must declare it.

1 Answers   Google,


Write a C program to enter 10 integer numbers through one variable and count how many of them are even using while loop ?

2 Answers  


Categories