3-The Basics Part 2
3-The Basics Part 2
Mathematical expression:
Multiplication * , adding + , subtracting - , dividing / and modulus % are the main operator
discussed , please note that when dividing int by int it will result by int and when dividing int by
double it will result by double, but you need to define you result as double
Int x = 3 ;
double y = 2.0 ;
Order of operations :
Any thing between parentheses is evaluated first like (2 + 2 ) * 9 the twos will be evaluated first the
order is as follow parentheses , power , multiplication and divide , adding and subtracting .
there is a few operate to simplify the printing to the console instead of using std every time you can
put
cout << “hello world” << endl ; // start a new line if you print a new one
also you can nest more than two
cout << “hello world ” << << “mister wonderful” << endl
Like the standard insertion operator there is also standard extraction operator to extract text from
the console using >>
Using
Cin >> variable name you can extract text from the console and do operation on it .
String name; ;
Cin>> name ;