468,512 Members | 1,147 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

Sequence of statements

10
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 ).
Oct 11 '06 #1
1 5083
koder
23
Hi,
is the below code answer your queries?

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2.  
  3. main()
  4. {
  5.  
  6.     int total=0,i,amount=0;
  7.      for(i=1;i<=3;i++)
  8.         {
  9.           printf("\nenter amount" );
  10.           scanf("%d",&amount);
  11.           total=total+amount;
  12.         }
  13.     printf("\ntottal= %d",total);
  14.     }
~
Oct 11 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by bird | last post: by
1 post views Thread by Hemant Shah | last post: by
5 posts views Thread by Senthil | last post: by
6 posts views Thread by newtophp2000 | last post: by
17 posts views Thread by Frederick Gotham | last post: by
2 posts views Thread by ais523 | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.