Lecture# 19 Simple Calculator Application using if-statement| C++ Programming Tutorials in Urdu

Write a program to perform simple calculation

include"iostream"
using namespace std;
main()
{
char ch;
int a,b,sum,sub,mul,div;
cout<<"Enter first number = ";
cin>>a;
cout<<"Enter choice (+,-,,/) = ";
cin>>ch;
cout<<"Enter second number = ";
cin>>b;
if(ch == '+')
{ sum = a+b;
cout<<"Sum = "<<sum;
}
else if(ch == '-')
{ sub = a-b;
cout<<"Sub = "<<sub;
}
else if(ch == '*')
{ mul = a*b;
cout<<"Mul = "<<mul;
}
else if(ch == '/')
{ div = a/b;
cout<<"Div = "<<div;
}
else
cout<<"Invalide";

Watch video for more information

Leave a Reply