Lecture-6 (26-09-2023)
Lecture-6 (26-09-2023)
MA144:
Computer Programming
Lecture-6
Control Structures
Arithmetic Operators
Binary operators : + - * / %
The % operator can not be applied to floating-point type
• C++ allows only one kind of parentheses ( ) in arithmetic
expressions.
• The other varieties are reserved for other purposes.
• If you omit parentheses, the computer will follow some
rules called precedence rules to evaluate an expression.
Highest precedence
Lowest precedence
Observe: 𝑥 3 = 𝑥 ∗ 𝑥 ∗ 𝑥
Arithmetic operators are executed left to right
when operators have the same precedence
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int a,b;
cout<<"enter two numbers: ";
cin>>a>>b;
if (a<b)
cout<<"i am in if block\n";
else;
cout<<"How crazy you are";
return 0;
}
Thank You