"how to make a calculator in c++" Code Answer's

You're definitely familiar with the best coding language C++ that developers use to develop their projects and they get all their queries like "how to make a calculator in c++" answered properly. Developers are finding an appropriate answer about how to make a calculator in c++ related to the C++ coding language. By visiting this online portal developers get answers concerning C++ codes question like how to make a calculator in c++. Enter your desired code related query in the search bar and get every piece of information about C++ code related question on how to make a calculator in c++. 

how to make a calculator inc++

By breezebreeze on Aug 30, 2020
// ONLY 29 LINES OF CODE IN TOTAL
// For better calculator scroll down on this post
#include <iostream>
using namespace std;
int main() {
	cout << "Please enter the first number: ";
	double n1 = 0;
	cin >> n1;
	cout << "Please enter an operator (+, -, *, /): ";
	char op = '0';
	cin >> op;
	cout << "Please enter a second number: ";
	double n2 = 0;
	cin >> n2;
	double answer = 0;
	switch (op) {
	case '+': 
		answer = n1 + n2;
		break;
	case '-':
		answer = n1 - n2;
		break;
	case '*': 
		answer = n1 * n2;
		break;
	case '/': 
		answer = n1 / n2;
		break;
	}
	cout << "Thanks for using my calculator your answer is: " << answer;
  
  // this is the better calculator:
  
  #include <iostream>
#include <Windows.h>
using namespace std;
int main() {
	char jim = 'j';
	do {
		
		cout << "Please enter the first number: ";
		double n1 = 0;
		cin >> n1;
		cout << "Please enter an operator (+, -, *, /): ";
		char op = '0';
		cin >> op;
		cout << "Please enter a second number: ";
		double n2 = 0;
		cin >> n2;
		double answer = 0;
		switch (op) {
		case '+':
			answer = n1 + n2;
			break;
		case '-':
			answer = n1 - n2;
			break;
		case '*':
			answer = n1 * n2;
			break;
		case '/':
			answer = n1 / n2;
			break;
		}
		cout << "Thanks for using my calculator your answer is: " << answer << " do you want to run the program again? (y or n) ";
		cin >> jim;

	} while (jim = 'y' && jim != 'n');
	if (jim = 'n') {
		cout << "Thanks for using my calculator here is sum epic music";
		Beep(329, 300);
		Beep(493, 300);
		Beep(698, 300);
		Beep(659, 600);

		Beep(783, 300);
		Beep(698, 300);
		Beep(659, 600);

		Beep(329, 100);
		Beep(493, 300);
		Beep(698, 300);
		Beep(659, 600);

		Beep(392, 250);
		Beep(440, 200);
		Beep(587, 300);

		Beep(349, 250);
		Beep(587, 500);

		Beep(329, 300);
		Beep(493, 300);
		Beep(698, 300);
		Beep(659, 600);

		Beep(783, 300);
		Beep(698, 300);
		Beep(659, 600);

		Beep(329, 100);
		Beep(493, 300);
		Beep(698, 300);
		Beep(659, 600);

		Beep(392, 250);
		Beep(440, 200);
		Beep(587, 300);

		Beep(349, 250);
		Beep(587, 400);
	}
	return 0;
}

Add Comment

2

c++ calculator program using switch case

By Bored BugBored Bug on May 22, 2020
#include<iostream>
using namespace std;
int calculator(int num1,int num2,int num3);
int main()
{
    //int num1,num2,num3,choice;
    int a,b,c,choice;
    cout<<"enter the first number"<<endl;
    cin>>a;
    cout<<"enter the second number"<<endl;
    cin>>b;
    cout<<"************************"<<endl;
    cout<<"****Make your choice****"<<endl;
    cout<<"1.Addition"<<endl;
    cout<<"2.Subtraction"<<endl;
    cout<<"3.Multiplication"<<endl;
    cout<<"4.Division"<<endl;
    cout<<"************************"<<endl;

    choice=calculator(a,b,c);
    return 0;
}
int calculator(int num1,int num2,int num3)
{

    int choice;
    cin>>choice;
    switch(choice)
    {

        case 1: cout<<"you have selected Addition"<<endl;
                num3=num1+num2;
                cout<<"Addition of two numbers is "<<num3<<endl;
                break;

        case 2: cout<<"you have selected Subtraction"<<endl;
                num3=num1-num2;
                cout<<"Subtraction of two numbers is "<<num3<<endl;
                break;

        case 3: cout<<"you have selected Multiplication"<<endl;
                num3=num1*num2;
                cout<<"Multiplication of two numbers is "<<num3<<endl;
                break;

        case 4: cout<<"You have selected Division"<<endl;
                num3=num1/num2;
                cout<<"Division of two numbers is "<<num3<<endl;
                break;

        default: cout<<"You have entered wrong choice"<<endl;
                    break;
    }
}

Add Comment

2

c++ calculator

By ArmiaShadowsArmiaShadows on Mar 02, 2021
#include <iostream>
using namespace std;

int main() {
    char setOperator;
    float firstNum = 0.00, secondNum = 0.00;
    cout << "Enter your operater: +, -, *, /:  \n";
    cin >> setOperator;
    cout << "Enter your first calculation:  \n";
    cin >> firstNum;
    cout <<  "Enter your second calculation:  \n";
    cin >> secondNum;
    
    switch(setOperator) {
        case '+':
        cout << "The answer is: " <<firstNum + secondNum;
        break;
        
        case '-':
        cout << "The answer is:" << firstNum - secondNum;
        break;
        
        case '*':
        cout << "The answer is: " << firstNum * secondNum;
        break;
        
        case '/':
        cout << "The answer is: " << firstNum / secondNum;
        break;
    }
    return 0;
}

Add Comment

0

how to make a calculator in c++

By peppa pigpeppa pig on Aug 18, 2020
// This is for beginners

#include <iostream>

using namespace std;

void greetings() {
    cout << "welcome to the calculator made in c++ :D\n";
}

void instructions() {
    cout << "Here is the operators you can use + - / *\n";
}

int main()
{
    greetings();
    instructions();
    int num1, num2;
    char op;
    int result;
    char again = 'Y';

    while (again == 'y' || again == 'Y') {



        cout << "\nEnter your first digit: ";
        cin >> num1;

        cout << "\nEnter your operator digit: ";
        cin >> op;

        cout << "\nEnter your second digit: ";
        cin >> num2;

        if (op == '+') {
            result = num1 + num2;
        }
        else if (op == '-') {
            result = num1 - num2;
        }
        else if (op == '*') {
            result = num1 * num2;
        }
        else if (op == '/') {
            result = num1 / num2;
        }
        else {
            cout << "Invalid operator";
        }

        cout << "= " << result;
        cout << "\nDo you want to restart the calculator? (Y or N)";
        cin >> again;
    }

    system("pause>0");

    return 0;
}

Add Comment

0

calculator with c++

By moghaazimoghaazi on Mar 16, 2021
#include <iostream>
using namespace std;

int main()
{
	int choice;

	cout << 1 << endl;
	cout << 2 << endl;
	cout << 3 << endl;
	cout << 4 << endl;

	cout << "Choice A Number: ";
	cin >> choice;

	if (choice >= 1 && choice <= 4)
	{
		int a, b;

		cout << "Enter Num One: ";
		cin >> a;
		cout << "Enter Num Two: ";
		cin >> b;

		if (choice == 1)
			cout << a << "+" << b << "=" << a + b << endl;
		if (choice == 2)
			cout << a << "-" << b << "=" << a - b << endl;
		if (choice == 3)
			cout << a << "*" << b << "=" << a * b << endl;
	}
	else
	{
		cout << "Wrong Choice" << endl;
	}
}

Add Comment

0

how to build a calculator using c++

on Jul 24, 2020
#include <iostream>

using namespace std;

int main()
{
int num1;
int num2;
char op;
  
  cout << "Enter a number:" << endl;
  cin >> num1; //takes input
  
  cout << "Enter another number:" << endl; //prints some prompt
  cin >> num2;
  
  cout << "Enter a operator:" << endl; //prints some prompt
  cin >> op;
  
  if(op == '+')
  {
  cout << "Result = " << num1 + num2 << endl;
  }else if(op == '-'){
  cout << "Result = " << num1 - num2 << endl;
  }else if(op == '*'){
  cout << "Result = " << num1 * num2 << endl;
  }else if(op == '/'){
  cout << "Result = " << num1 / num2 << endl;
  }
  
  
}

Add Comment

-1

All those coders who are working on the C++ based application and are stuck on how to make a calculator in c++ can get a collection of related answers to their query. Programmers need to enter their query on how to make a calculator in c++ related to C++ code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about how to make a calculator in c++ for the programmers working on C++ code while coding their module. Coders are also allowed to rectify already present answers of how to make a calculator in c++ while working on the C++ language code. Developers can add up suggestions if they deem fit any other answer relating to "how to make a calculator in c++". Visit this developer's friendly online web community, CodeProZone, and get your queries like how to make a calculator in c++ resolved professionally and stay updated to the latest C++ updates. 

C++ answers related to "how to make a calculator in c++"

View All C++ queries

C++ queries related to "how to make a calculator in c++"

how to make a calculator inc++ how to make a calculator in c++ how to make a adittion calculator in c++ c++ calculator program using switch case c++ calculator script calculator with c++ c++ calculator primtiive calculator in c++ how to build a calculator using c++ run time calculator c++ how to make sure the user inputs a int and not anything else c++ how to make a Loop in c++ c++ how to make a negative float positive make cin cout faster how to make crypto how can make string value in cpp c++ make shared_ptr how to make string get spaces c++ how to make a random number in c++ how to make a list in c++ how to make a switch case statement in c++ how to make an array c++ how to make a selection sort C++ How to make a function in C++ how to make a n*n 2d dynamic array in c++ how to make a vector in c++ how to make a login c++ make random nuber between two number in c++ how to make a 2d vector in c++ how to make a typing effect c++ make a token how to make for loop in c++ how to make a array in c++ qt make widget ignore mouse events how to make rng in c++ make pair in c++ cpp make class abstract how to make a function in cpp how to make graphs in c++ c++ modulo make it give only positive numbers make pair map c++ make vector loop more faster how to make movement in c++ unreal how to make an enum in c++ hwo to make a script to give track battery and give notification how to make a comment in c++ c++ how to make function as argument how to make a while Loop in c++ how to make custom domain extension how to make a c++ iostream program restart when finished make an x using asterisk c++ how to make 2d vector

Browse Other Code Languages

CodeProZone