Unknown Unknown Author
Title: C++ Programming How to Make a Simple Calculator
Author: Unknown
Rating 5 of 5 Des:
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++ L...

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;

        }
        else
            cout << "Invalid operator ";



    return 0;
}


Output Of the Program :



Advertisement

Post a Comment

Please Don't Spam You are allowed to comment your website link

 
Top