Sequence Choice Repete Assignment ` x = 3 + y; ` If-statement ``` if( a >= b ) b=a; else b=-a;``` While-statement ``` while( i <= 100 ) { i++; sum += i; } ``` I/O statements ``` cout << "Hello"; cin >> x; ``` Short if ` b = ( a >= 0 ) ? a : -a; ` do-statement ``` do { i++; sum += i; } while( i <= 99 ); ``` Arithmetic ops ``` + - * / % += -= *= /= ++ -- ``` Switch statement ``` char op; switch( op ) { case '*': z = x*y;break; case '+': z = x+y;break; default: cout << "Error\n"; } ``` for-statement ``` for( i= 0 ; i <= 100 ; i++ ) sum += i; ``` Compound statement ``` { x = y + 1; // A comment here y = 3; z = 5*a; } ``` Logical and relational ops ``` == < > <= >= != && || ! & | ```

Function definition and main program on one file:
``````

#include <iostream.h>

void fcn( int x, int y )
{
cout << x*y << endl;
}

int main()
{
...
fcn(1,2);
...
}
``````
If the file is called ` main.C `, can compile with
`````` CC main.C
``````

or
`````` g++ main.C
``````

Can divide to have one file for the function. Function declaration and main program on one file:
``````

#include <iostream.h>

void fcn( int x, int y );

int main()
{
...
fcn(1,2);
...
}
``````
Call this file ` main.C `. A second file with the function definition:
``````
void fcn( int x, int y )
{
cout << x*y << endl;
}
``````
called, for example, ` fcn.C `. The program is then compiled with
`````` CC main.C fcn.C
``````

or
`````` g++ main.C fcn.C
``````