For Simple Sample Program In C + +

Kamis, 17 November 2011
In C + + programming language for looping (looping) the most commonly used is the For statement. For statement is useful for looping (looping) of one or a number of statements.

A simple example is to display writing C + + as much as 10 times, like the example program below:
01 # include <iostream>
02 # include <conio.h>
03
04 void main ()
05 {
06 clrscr ();
07 int i;
08 for (i = 0; i <10; i + +)
09 {
10 court <<"C ++"<< endl;
11}
12 getch ();
13}

Simple Explanation For Statement In C + + program above:

First we create a new variable of type integer i with. In a statement for, i was given an initial value is 0. Then do the test if i <10, because the result is true then the statement inside the For run. Then do the increment of i in the statement i + +. Further testing is done again if i <10. If yes (true) then in the For statement is executed, if not then proceed to the program under For. And so on until the test i <10 is false.

0 komentar: On For Simple Sample Program In C + +

Posting Komentar

Grab this Widget ~ Blogger Accessories
 
bottom