how to create simple calculator in c++ by using simple programming,or using if and else if combination in c++ programming
Creating Simple Calculator in C++ | Using if and else if |
1st one is Creating Simple Calculator in C++
so follow is the code given to convert temperature just do practice and learn programming
2nd one is Using if and else if
its code is also given below so do same and practice in case of any confusion and misunderstanding of any thing then please send us feedback at contact us forum or use our comment forum to leave your comments
thanks for reading us
Creating Simple Calculator in C++ | Using if and else if |
#include<iostream>
#include<conio.h>
using namespace std;
int main ()
{
float num1, num2;
char choice;
cout<<"Enter Value 1=";
cin>>num1;
cout<<"Enter Value 2=";
cin>>num2;
cout<<"Enter + for Addition\nEnter - for Substraction\nEnter * for Multiplication\nEnter / for Division";
cin>>choice;
if (choice=='+')
cout<<"Addition"<<num1+num2;
else if(choice=='-')
cout<<"Substraction"<<num1-num2;
else if(choice=='*')
cout<<"Substraction"<<num1*num2;
else if(choice=='/')
cout<<"Division"<<num1/num2;
else
cout<<"Wrong Number";
getch();
return 0;
}
COMMENTS