C++ variables

C++ variables
1
C++ workshop, Amir Tosson
The structure
2
C++ workshop, Amir Tosson
Char list
3
C++ workshop, Amir Tosson
Operators
4
C++ workshop, Amir Tosson
Conditional operator ( ? )
(condition) ? Result1 : Result2 ;
If the condition is true the prog. returns Result1
If NOT returns Result2
5
C++ workshop, Amir Tosson
I/o basics
 Ex1: Code to read-in three numbers from the user and sum
and average them and then print out the sum and average.
6
C++ workshop, Amir Tosson
Random numbers Generator
 To set the seed
srand ();
 To generate
rand ();
But a new lib needs to be included;
<cstdlib>
7
C++ workshop, Amir Tosson
Arrays
int arr[5]= {1,2,3,4,5};
Components
Type of your array
arr[0]=1
arr[1]=2
arr[2]=3
arr[3]=4
arr[4]=5
8
Name
Size
(ex 2 : code to set an array size =3
3 numbers from user and show them)
C++ workshop, Amir Tosson
For loop
For (the condition)
{ what to do }
For (int i= 0 ; i<10; i++){
cout<< i<< endl;
}
Try ec2 with for loop
9
C++ workshop, Amir Tosson
Ex3
 Code to generate array as user wants, give it a name , the
user will fill it, show it to the user.
 Then do some mathmatical calculations, show your results.
10
C++ workshop, Amir Tosson