473,561 Members | 3,123 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sequence of statements

10 New Member
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 5343
23 New Member
is the below code answer your queries?

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  3. main()
  4. {
  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

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

Similar topics

by: bird | last post by:
I need to execute a sequence of mysql statements, like creating a new database, then creating a few tables, and then copy some records from tables of an old database to this new one. what's the best way to implement it with PHP? I think I shall write a SQL script file, and let PHP read and execute it. Am I right here? How shall I deal with...
by: Hemant Shah | last post by:
Folks, I am having problem running select query from a sequence. I get SQL0204N error. I am running UDB 8.2 on AIX 5.2. # oslevel # db2level DB21085I Instance "dba2test" uses "32" bits and DB2 code release "SQL08021"
by: Senthil | last post by:
Hi, When standard states this " i = v; // the behavior is undefined i = ++i + 1; // the behavior is undefined " Do both of the following code snippets produces undefined behaviour or the second one alone.
by: newtophp2000 | last post by:
Hello, Since SQL Server has no sequence generator, I wrote my own. (I claim no ownership of it as it is closely modeled after earlier discussions on this topic.) I have included the sql statements below. While it works independently on its own, It seems to lock in multi-user environments or in nested-transactions. It s funny really: I...
by: Frederick Gotham | last post by:
I know there's a sequence point at a comma, e.g.: int main(void) { int a = 1; a++, ++a, a *= 3, a <<= 4; /* Perfectly okay */ }
by: simun.selak | last post by:
On my local installation of DB2 on AS/400 (BTW., how do I find out which version od DB2 I have?) I have created these SQL statements: CREATE SEQUENCE a.seq AS INTEGER START WITH 8955 INCREMENT BY 1 INSERT INTO a.table1 (id, name) SELECT (next value for a.seq, name) from a.table2
by: ais523 | last post by:
The program excerpt int i; char c; char* a= {"abc","def","ghi"}; /* ... */ i=0; c=a; obviously invokes undefined behaviour, because i is modified twice
by: somenath | last post by:
Hi All, I have one question regarding the conditional operator. In the draft C99 standard it is mentioned that "1 The following are the sequence points described in -- The call to a function, after the arguments have been evaluated ( -- The end of the first operand of the following operators: logical AND && (6.5.13);
by: joe | last post by:
Consider the following program: include <iostream> class Bar { public: int getData9() { m_data = 9; return m_data;} int getData11() { m_data = 11; return m_data;} int m_data;
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.