-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path07operators.cpp
More file actions
41 lines (38 loc) · 1.65 KB
/
07operators.cpp
File metadata and controls
41 lines (38 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include<iostream>
using namespace std;
int main(){
int a=4, b=5;
// Arithmetic Operators
cout<<"The value of a and b is: "<<a<<" and "<<b<<endl;
cout<<"Following are the arithmetic operators in C++"<<endl;
cout<<"The value of a+b is: "<<a+b<<endl; // endl for linebreak
cout<<"The value of a-b is: "<<a-b<<endl;
cout<<"The value of a*b is: "<<a*b<<endl;
cout<<"The value of a/b is: "<<a/b<<endl;
cout<<"The value of a%b is: "<<a%b<<endl;
cout<<"The value of a++ is: "<<a++<<endl;
cout<<"The value of b-- is: "<<b--<<endl;
cout<<"The value of ++a is: "<<++a<<endl;
cout<<"The value of --b is: "<<--b<<endl;
cout<<endl;
// Assignment Operators
// int c=8, d=10;
// char e='f';
// Comparison Operators
cout<<"The value of a and b is: "<<a<<" and "<<b<<endl;
cout<<"Following are the comparison operators in C++"<<endl;
cout<<"The value of a==b is: "<<(a==b)<<endl;
cout<<"The value of a!=b is: "<<(a!=b)<<endl;
cout<<"The value of a>b is: "<<(a>b)<<endl;
cout<<"The value of a<b is: "<<(a<b)<<endl;
cout<<"The value of a>=b is: "<<(a>=b)<<endl;
cout<<"The value of a<=b is: "<<(a<=b)<<endl;
cout<<endl;
// Logical Operators
cout<<"The value of a and b is: "<<a<<" and "<<b<<endl;
cout<<"Following are the comparison operators in C++"<<endl;
cout<<"The value of (a && b) is: "<<(a && b)<<endl; // non-zero value taken as 1 by && logical operators
cout<<"The value of (a || b) is: "<<(a || b)<<endl; // non-zero value taken as 1 by || logical operators
cout<<"The value of !(a==b) is: "<<!(a==b)<<endl;
cout<<endl;
}