Computer programming/Statements - eMyTextBooks

Search:  

Free online books - just read it!

See live article   •   Computer programming/Statements
 

Computer programming/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:

println "Hi there!"

This command has a verb ("println") and other details (what to print). In this case, the command "println" 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:

println "Hi there!"
println "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 println 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.


Also helps finding: ComputerprogrammingStatements, Computerprogramming, programmingStatements, compter, programing, statments, comptuer, programmin, staements, comuter, progamming, satements, computar, prgramming, statemnts

   
 
  
Add to bookmarks
Related Articles
 
Programming:Statements
Computer programming
Top Articles
 
Ada Programming/Keywords/end
Ada Programming/Keywords/private
Ada Programming/Keywords/range
Ada Programming/Keywords/record
Ada Programming/Keywords/then
Cookbook:Garlic
Cookbook:Milk
Cookbook:Recipes
Cookbook:Tomato
Electronics
IP address
Main Page
Radiation Oncology:RTOG Trials
Robotics
SA NCS:Consumer Studies
SA NCS:Dramatic Arts
SA NCS:Economy
SA NCS:Life Orientation
SA NCS:Tourism
Wikibooks Pokédex:Johto Index
Wikibooks Pokédex:National Index
Search LiveJournal blogs for Computer programming/Statements
 

Find jobs  •  Free Myspace Layouts  •  Credit Consolidation  •  Italian Property •  Silver Shop

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