C++ Programming How to Make a Simple Calculator
This program will show you to how to make simple Calculator using if/else statement in C++ Language.
Program # 3 : Calculator using if/else statement
#include <iostream>using namespace std;int main(){float a, b;char c;float R;cout << "Enter the First Number : \n";cin >> a;cout << "Enter the Second Number : \n";cin >> b;cout << "*****What to do?***** \n" << "+ For Addition \n" << "- For Subtraction \n" << "* For Multiplication \n" << "/ For Division \n " ;cin >> c;if(c=='+' ){R = a + b;cout << R;}else if(c=='-'){R = a - b;cout << R;}else if (c=='*'){R = a * b;cout << R;}else if(c=='/'){R = a / b ;cout << R;}elsecout << "Invalid operator ";return 0;}
Post a Comment
Please Don't Spam You are allowed to comment your website link