#include <iostream>
using namespace std;
int main()
{
char choice;
int a=7, b=2;
float op3=10.1,op4=5.4;
signed int x=4;
unsigned long int a1=10,b1=40;
signed long int a2=10,b2=8,c2=12,d2=15;
short int a3=4,b3=7,c3;
do{
cout<<"-------------------------------------------------------------n";
cout<<"A-Arithmetic Operators using Integer , Float & doublen";
cout<<"B-Increment & Decrement Operators signed Integern";
cout<<"C-Relational Operator Using unsigned long Integern";
cout<<"D-Logical Operator Using Signed long Integern";
cout<<"E-Bitwise Operator using signed Integern";
cout<<"F.Exitn";
cout<<"Enter Your Choice: ";
cin>>choice;
cout<<"-------------------------------------------------------------n";
switch(choice)
{
case 'A': cout<<"Arithmetic Operators using Integer & Floatn";
cout << "a + b = " << (a + b) << endl;
cout << "a - b = " << (a - b) << endl;
cout << "a * b = " << (a * b) << endl;
cout << "op3 / op4 = " << (op3 /op4) << endl;
cout << "a % b " << (a % b) << endl;
break;
case 'B': cout<<"Increment & Decrement Operators signed Integer "<< endl;
cout << "post Increment a++ is :" <<x++ << endl;
cout << "Post decrement a-- is :" <<x-- << endl;
cout << "pre Increment ++a is :" << ++x << endl;
cout << "Pre decrement --a is :" << --x << endl;
break;
case 'C': cout<<"Relational Operator Using unsigned long Integer"<< endl;
if (a1 == b1)
cout << "a1 == b1 is Equal" << endl;
else
cout << " a1 == b1 is not Equal" << endl;
if (a1 < b1)
cout << "a1 < b1 is true" << endl;
else
cout << "a1 < b1 is false" << endl;
break;
case 'D':cout<<"D-Bitwise Operator Using Signed long Integer"<< endl;
if((a2>b2)&&(c2<d2))
cout<<"Logical AND is Truen";
else
cout<<"Logical AND is Falsen";
if((a2<b2)||(c2<d2))
cout<<"Logical OR is Truen";
else
cout<<"Logical OR is Falsen";
break;
case 'E':cout<<"E-Bitwise Operator using Short Integer"<< endl;
c3=a3&b3;
cout<<"Result of a3 & b3 ="<<c3<<endl;
c3=a3|b3;
cout<<"Result of a3 | b3 ="<<c3<<endl;
c3=a3^b3;
cout<<"Result of a3 ^ b3 ="<<c3<<endl;
c3=a<<2;
cout<<"Result of a3 << 2 ="<<c3<<endl;
c3=b3>>2;
cout<<"Result of a3 >> 2 ="<<c3<<endl;
c3=~a3;
cout<<"Result of ~ a3 ="<<c3<<endl;
break;
case 'F':
exit(0);
}
}while(choice!='F');
return 0;
}
OUTPUT:
-------------------------------------------------------------
A-Arithmetic Operators using Integer , Float & double
B-Increment & Decrement Operators signed Integer
C-Relational Operator Using unsigned long Integer
D-Logical Operator Using Signed long Integer
E-Bitwise Operator using signed Integer
F.Exit
Enter Your ChoiceA
-------------------------------------------------------------
Arithmetic Operators using Integer & Float
a + b = 9
a - b = 5
a * b = 14
op3 / op4 = 1.87037
a % b 1
-------------------------------------------------------------
A-Arithmetic Operators using Integer , Float & double
B-Increment & Decrement Operators signed Integer
C-Relational Operator Using unsigned long Integer
D-Logical Operator Using Signed long Integer
E-Bitwise Operator using signed Integer
F.Exit
Enter Your ChoiceB
-------------------------------------------------------------
Increment & Decrement Operators signed Integer
post Increment a++ is :4
Post decrement a-- is :5
pre Increment ++a is :5
Pre decrement --a is :4
-------------------------------------------------------------
A-Arithmetic Operators using Integer , Float & double
B-Increment & Decrement Operators signed Integer
C-Relational Operator Using unsigned long Integer
D-Logical Operator Using Signed long Integer
E-Bitwise Operator using signed Integer
F.Exit
Enter Your ChoiceC
-------------------------------------------------------------
Relational Operator Using unsigned long Integer
a1 == b1 is not Equal
a1 < b1 is true
-------------------------------------------------------------
A-Arithmetic Operators using Integer , Float & double
B-Increment & Decrement Operators signed Integer
C-Relational Operator Using unsigned long Integer
D-Logical Operator Using Signed long Integer
E-Bitwise Operator using signed Integer
F.Exit
Enter Your ChoiceD
-------------------------------------------------------------
D-Bitwise Operator Using Signed long Integer
Logical AND is True
Logical OR is True
-------------------------------------------------------------
A-Arithmetic Operators using Integer , Float & double
B-Increment & Decrement Operators signed Integer
C-Relational Operator Using unsigned long Integer
D-Logical Operator Using Signed long Integer
E-Bitwise Operator using signed Integer
F.Exit
Enter Your ChoiceE
-------------------------------------------------------------
E-Bitwise Operator using Short Integer
Result of a3 & b3 =4
Result of a3 | b3 =7
Result of a3 ^ b3 =3
Result of a3 << 2 =28
Result of a3 >> 2 =1
Result of ~ a3 =-5
-------------------------------------------------------------
A-Arithmetic Operators using Integer , Float & double
B-Increment & Decrement Operators signed Integer
C-Relational Operator Using unsigned long Integer
D-Logical Operator Using Signed long Integer
E-Bitwise Operator using signed Integer
F.Exit
Enter Your ChoiceF
-------------------------------------------------------------
[Inferior 1 (process 575) exited normally]
(gdb)

c++ program using All data type and operators

  • 1.
    #include <iostream> using namespacestd; int main() { char choice; int a=7, b=2; float op3=10.1,op4=5.4; signed int x=4; unsigned long int a1=10,b1=40; signed long int a2=10,b2=8,c2=12,d2=15; short int a3=4,b3=7,c3; do{ cout<<"-------------------------------------------------------------n"; cout<<"A-Arithmetic Operators using Integer , Float & doublen"; cout<<"B-Increment & Decrement Operators signed Integern"; cout<<"C-Relational Operator Using unsigned long Integern"; cout<<"D-Logical Operator Using Signed long Integern"; cout<<"E-Bitwise Operator using signed Integern"; cout<<"F.Exitn"; cout<<"Enter Your Choice: "; cin>>choice; cout<<"-------------------------------------------------------------n"; switch(choice) { case 'A': cout<<"Arithmetic Operators using Integer & Floatn"; cout << "a + b = " << (a + b) << endl; cout << "a - b = " << (a - b) << endl; cout << "a * b = " << (a * b) << endl; cout << "op3 / op4 = " << (op3 /op4) << endl; cout << "a % b " << (a % b) << endl; break;
  • 2.
    case 'B': cout<<"Increment& Decrement Operators signed Integer "<< endl; cout << "post Increment a++ is :" <<x++ << endl; cout << "Post decrement a-- is :" <<x-- << endl; cout << "pre Increment ++a is :" << ++x << endl; cout << "Pre decrement --a is :" << --x << endl; break; case 'C': cout<<"Relational Operator Using unsigned long Integer"<< endl; if (a1 == b1) cout << "a1 == b1 is Equal" << endl; else cout << " a1 == b1 is not Equal" << endl; if (a1 < b1) cout << "a1 < b1 is true" << endl; else cout << "a1 < b1 is false" << endl; break; case 'D':cout<<"D-Bitwise Operator Using Signed long Integer"<< endl; if((a2>b2)&&(c2<d2)) cout<<"Logical AND is Truen"; else cout<<"Logical AND is Falsen"; if((a2<b2)||(c2<d2)) cout<<"Logical OR is Truen"; else cout<<"Logical OR is Falsen"; break; case 'E':cout<<"E-Bitwise Operator using Short Integer"<< endl; c3=a3&b3; cout<<"Result of a3 & b3 ="<<c3<<endl; c3=a3|b3; cout<<"Result of a3 | b3 ="<<c3<<endl;
  • 3.
    c3=a3^b3; cout<<"Result of a3^ b3 ="<<c3<<endl; c3=a<<2; cout<<"Result of a3 << 2 ="<<c3<<endl; c3=b3>>2; cout<<"Result of a3 >> 2 ="<<c3<<endl; c3=~a3; cout<<"Result of ~ a3 ="<<c3<<endl; break; case 'F': exit(0); } }while(choice!='F'); return 0; } OUTPUT: ------------------------------------------------------------- A-Arithmetic Operators using Integer , Float & double B-Increment & Decrement Operators signed Integer C-Relational Operator Using unsigned long Integer D-Logical Operator Using Signed long Integer E-Bitwise Operator using signed Integer F.Exit Enter Your ChoiceA ------------------------------------------------------------- Arithmetic Operators using Integer & Float a + b = 9 a - b = 5 a * b = 14 op3 / op4 = 1.87037 a % b 1 ------------------------------------------------------------- A-Arithmetic Operators using Integer , Float & double B-Increment & Decrement Operators signed Integer C-Relational Operator Using unsigned long Integer D-Logical Operator Using Signed long Integer E-Bitwise Operator using signed Integer F.Exit Enter Your ChoiceB ------------------------------------------------------------- Increment & Decrement Operators signed Integer post Increment a++ is :4 Post decrement a-- is :5 pre Increment ++a is :5
  • 4.
    Pre decrement --ais :4 ------------------------------------------------------------- A-Arithmetic Operators using Integer , Float & double B-Increment & Decrement Operators signed Integer C-Relational Operator Using unsigned long Integer D-Logical Operator Using Signed long Integer E-Bitwise Operator using signed Integer F.Exit Enter Your ChoiceC ------------------------------------------------------------- Relational Operator Using unsigned long Integer a1 == b1 is not Equal a1 < b1 is true ------------------------------------------------------------- A-Arithmetic Operators using Integer , Float & double B-Increment & Decrement Operators signed Integer C-Relational Operator Using unsigned long Integer D-Logical Operator Using Signed long Integer E-Bitwise Operator using signed Integer F.Exit Enter Your ChoiceD ------------------------------------------------------------- D-Bitwise Operator Using Signed long Integer Logical AND is True Logical OR is True ------------------------------------------------------------- A-Arithmetic Operators using Integer , Float & double B-Increment & Decrement Operators signed Integer C-Relational Operator Using unsigned long Integer D-Logical Operator Using Signed long Integer E-Bitwise Operator using signed Integer F.Exit Enter Your ChoiceE ------------------------------------------------------------- E-Bitwise Operator using Short Integer Result of a3 & b3 =4 Result of a3 | b3 =7 Result of a3 ^ b3 =3 Result of a3 << 2 =28 Result of a3 >> 2 =1 Result of ~ a3 =-5 ------------------------------------------------------------- A-Arithmetic Operators using Integer , Float & double B-Increment & Decrement Operators signed Integer C-Relational Operator Using unsigned long Integer D-Logical Operator Using Signed long Integer E-Bitwise Operator using signed Integer F.Exit Enter Your ChoiceF ------------------------------------------------------------- [Inferior 1 (process 575) exited normally] (gdb)