|
Programming -
C/C++
|
|
Saturday, 11 July 2009 08:16 |

Basic If Syntax The structure of an if statement is as follows: if ( TRUE ) Execute the next statement
Here is a simple example that shows the syntax: if ( 5 < 10 ) cout<<"Five is now less than ten, that's a big surprise";
Here, we're just evaluating the statement, "is five less than ten", to see if it is true or not; with any luck, it's not! If you want, you can write your own full program including iostream and put this in the main function and run it to test.
|
|
Last Updated on Monday, 13 July 2009 23:28 |
|
Programming -
C/C++
|
|
Thursday, 09 July 2009 00:07 |
Declaring Variables in C++ To declare a variable you use the syntax "type ;". Here are some variable declaration examples:
|
|
Last Updated on Thursday, 09 July 2009 07:48 |
|
Programming -
C/C++
|
|
Tuesday, 07 July 2009 22:40 |
A C++ program is a collection of commands, which tell the computer to do "something". This collection of commands is usually called C++ source code, source code or just code. Commands are either "functions" or "keywords". Keywords are a basic building block of the language, while functions are, in fact, usually written in terms of simpler functions--you'll see this in our very first program, below. (Confused? Think of it a bit like an outline for a book; the outline might show every chapter in the book; each chapter might have its own outline, composed of sections. Each section might have its own outline, or it might have all of the details written up.) Thankfully, C++ provides a great many common functions and keywords that you can use.
But how does a program actually start? Every program in C++ has one function, always named main, that is always called when your program first executes. From main, you can also call other functions whether they are written by us or, as mentioned earlier, provided by the compiler.
|
|
|
|
|