Programming:C plus plus:Statements - eMyTextBooks

Search:  

Free online books - just read it!

See live article   •   Programming:C plus plus:Statements
 

Programming:C plus plus:Statements

This Computer programming article is available in pseudocode, Ada, C, C++ and Python.

Table of contents

Note: there are some simplifications in the explanations below. Don't take anything too literally.

Most programming languages have the concept of a statement. A statement is a command that the programmer gives to the computer. For example:

cout << "Hi there!";

This command has a verb ("cout") and other details (what to print). In this case, the command "cout" means "show on the screen," not "print on the printer." The programmer either gives the statement directly to the computer (by typing it while running a special program), or creates a text file with the command in it. You could create a file called "hi.txt", put the above command in it, and give the file to the computer.

If you have more than one command in the file, each will be performed in order, top to bottom. So the file could contain:

cout << "Hi there!";
cout << "Strange things are afoot...";

The computer will perform each of these commands sequentially. It's invaluable to be able to "play computer" when programming. Ask yourself, "If I were the computer, what would I do with these statements?" If you're not sure what the answer is, then you are very likely to write incorrect code. Stop and check the manual for the programming language you're using.

In the above case, the computer will look at the first statement, determine that it's a cout statement, look at what needs to be printed, and display that text on the computer screen. It'll look like this:

Hi there!

Note that the quotation marks aren't there. Their purpose in the program is to tell the computer where the text begins and ends, just like in English prose. The computer will then continue to the next statement, perform its command, and the screen will look like this:

Hi there!
Strange things are afoot...

When the computer gets to the end of the text file, it stops. There are many different kinds of statements, depending on which programming language is being used. For example, there could be a beep statement that causes the computer to output a beep on its speaker, or a window statement that causes a new window to pop up.

Also, the way statements are written will vary depending on the programming language. These differences are fairly superficial. The set of rules like the first two is called a programming language's syntax. The set of verbs is called its library.

This article is available in wikibook pseudocode, Ada, C, C++ and Python - do have a look at the other languages as well.


Back to contents: C programming


Also helps finding: ProgrammingCplusplusStatements, ProgrammingC, Cplus, plusplus, plusStatements, programing, pls, statments, programmin, plu, staements, progamming, pluss, satements, prgramming

   
 
  
Add to bookmarks
Top Articles
 
Ada Programming/Keywords/and
Ada Programming/Keywords/array
Ada Programming/Keywords/for
Ada Programming/Keywords/in
Ada Programming/Keywords/is
Ada Programming/Keywords/procedure
Ada Programming/Keywords/then
Cookbook:Basic foodstuffs
Cookbook:Sugar
Cookbook:Tablespoon
FHSST Physics
IP address
Programming:C
Radiation Oncology
SA CUR Info
SA NCS
SA NCS:Engineering Graphics and Design
SA NCS:Hospitality Studies
SA NCS:Qualification Assesment
Wikibooks Pokédex:Hoenn Index
Wikibooks Pokédex:National Index
Search LiveJournal blogs for Programming:C plus plus:Statements
 

Credit Consolidation  •  Credit Consolidation  •  Wordpress Themes  •  Credit Consolidation •  Geckos

Copyright @ 2005 eMyTextBooks.com
This article is from Wikibooks. All text is available under the terms of the GNU Free Documentation License.