how to make a calculator in c 2b 2b

Solutions on MaxInterview for how to make a calculator in c 2b 2b by the best coders in the world

showing results for - "how to make a calculator in c 2b 2b"
Tomas
01 Nov 2020
1// ONLY 29 LINES OF CODE IN TOTAL
2// For better calculator scroll down on this post
3#include <iostream>
4using namespace std;
5int main() {
6	cout << "Please enter the first number: ";
7	double n1 = 0;
8	cin >> n1;
9	cout << "Please enter an operator (+, -, *, /): ";
10	char op = '0';
11	cin >> op;
12	cout << "Please enter a second number: ";
13	double n2 = 0;
14	cin >> n2;
15	double answer = 0;
16	switch (op) {
17	case '+': 
18		answer = n1 + n2;
19		break;
20	case '-':
21		answer = n1 - n2;
22		break;
23	case '*': 
24		answer = n1 * n2;
25		break;
26	case '/': 
27		answer = n1 / n2;
28		break;
29	}
30	cout << "Thanks for using my calculator your answer is: " << answer;
31  
32  // this is the better calculator:
33  
34  #include <iostream>
35#include <Windows.h>
36using namespace std;
37int main() {
38	char jim = 'j';
39	do {
40		
41		cout << "Please enter the first number: ";
42		double n1 = 0;
43		cin >> n1;
44		cout << "Please enter an operator (+, -, *, /): ";
45		char op = '0';
46		cin >> op;
47		cout << "Please enter a second number: ";
48		double n2 = 0;
49		cin >> n2;
50		double answer = 0;
51		switch (op) {
52		case '+':
53			answer = n1 + n2;
54			break;
55		case '-':
56			answer = n1 - n2;
57			break;
58		case '*':
59			answer = n1 * n2;
60			break;
61		case '/':
62			answer = n1 / n2;
63			break;
64		}
65		cout << "Thanks for using my calculator your answer is: " << answer << " do you want to run the program again? (y or n) ";
66		cin >> jim;
67
68	} while (jim = 'y' && jim != 'n');
69	if (jim = 'n') {
70		cout << "Thanks for using my calculator here is sum epic music";
71		Beep(329, 300);
72		Beep(493, 300);
73		Beep(698, 300);
74		Beep(659, 600);
75
76		Beep(783, 300);
77		Beep(698, 300);
78		Beep(659, 600);
79
80		Beep(329, 100);
81		Beep(493, 300);
82		Beep(698, 300);
83		Beep(659, 600);
84
85		Beep(392, 250);
86		Beep(440, 200);
87		Beep(587, 300);
88
89		Beep(349, 250);
90		Beep(587, 500);
91
92		Beep(329, 300);
93		Beep(493, 300);
94		Beep(698, 300);
95		Beep(659, 600);
96
97		Beep(783, 300);
98		Beep(698, 300);
99		Beep(659, 600);
100
101		Beep(329, 100);
102		Beep(493, 300);
103		Beep(698, 300);
104		Beep(659, 600);
105
106		Beep(392, 250);
107		Beep(440, 200);
108		Beep(587, 300);
109
110		Beep(349, 250);
111		Beep(587, 400);
112	}
113	return 0;
114}
Fia
02 Jan 2021
1#include<iostream>
2using namespace std;
3int calculator(int num1,int num2,int num3);
4int main()
5{
6    //int num1,num2,num3,choice;
7    int a,b,c,choice;
8    cout<<"enter the first number"<<endl;
9    cin>>a;
10    cout<<"enter the second number"<<endl;
11    cin>>b;
12    cout<<"************************"<<endl;
13    cout<<"****Make your choice****"<<endl;
14    cout<<"1.Addition"<<endl;
15    cout<<"2.Subtraction"<<endl;
16    cout<<"3.Multiplication"<<endl;
17    cout<<"4.Division"<<endl;
18    cout<<"************************"<<endl;
19
20    choice=calculator(a,b,c);
21    return 0;
22}
23int calculator(int num1,int num2,int num3)
24{
25
26    int choice;
27    cin>>choice;
28    switch(choice)
29    {
30
31        case 1: cout<<"you have selected Addition"<<endl;
32                num3=num1+num2;
33                cout<<"Addition of two numbers is "<<num3<<endl;
34                break;
35
36        case 2: cout<<"you have selected Subtraction"<<endl;
37                num3=num1-num2;
38                cout<<"Subtraction of two numbers is "<<num3<<endl;
39                break;
40
41        case 3: cout<<"you have selected Multiplication"<<endl;
42                num3=num1*num2;
43                cout<<"Multiplication of two numbers is "<<num3<<endl;
44                break;
45
46        case 4: cout<<"You have selected Division"<<endl;
47                num3=num1/num2;
48                cout<<"Division of two numbers is "<<num3<<endl;
49                break;
50
51        default: cout<<"You have entered wrong choice"<<endl;
52                    break;
53    }
54}
55
56
Laura
18 Aug 2020
1#include <iostream>
2using namespace std;
3
4int main() {
5    char setOperator;
6    float firstNum = 0.00, secondNum = 0.00;
7    cout << "Enter your operater: +, -, *, /:  \n";
8    cin >> setOperator;
9    cout << "Enter your first calculation:  \n";
10    cin >> firstNum;
11    cout <<  "Enter your second calculation:  \n";
12    cin >> secondNum;
13    
14    switch(setOperator) {
15        case '+':
16        cout << "The answer is: " <<firstNum + secondNum;
17        break;
18        
19        case '-':
20        cout << "The answer is:" << firstNum - secondNum;
21        break;
22        
23        case '*':
24        cout << "The answer is: " << firstNum * secondNum;
25        break;
26        
27        case '/':
28        cout << "The answer is: " << firstNum / secondNum;
29        break;
30    }
31    return 0;
32}
Laura
09 Feb 2020
1// This is for beginners
2
3#include <iostream>
4
5using namespace std;
6
7void greetings() {
8    cout << "welcome to the calculator made in c++ :D\n";
9}
10
11void instructions() {
12    cout << "Here is the operators you can use + - / *\n";
13}
14
15int main()
16{
17    greetings();
18    instructions();
19    int num1, num2;
20    char op;
21    int result;
22    char again = 'Y';
23
24    while (again == 'y' || again == 'Y') {
25
26
27
28        cout << "\nEnter your first digit: ";
29        cin >> num1;
30
31        cout << "\nEnter your operator digit: ";
32        cin >> op;
33
34        cout << "\nEnter your second digit: ";
35        cin >> num2;
36
37        if (op == '+') {
38            result = num1 + num2;
39        }
40        else if (op == '-') {
41            result = num1 - num2;
42        }
43        else if (op == '*') {
44            result = num1 * num2;
45        }
46        else if (op == '/') {
47            result = num1 / num2;
48        }
49        else {
50            cout << "Invalid operator";
51        }
52
53        cout << "= " << result;
54        cout << "\nDo you want to restart the calculator? (Y or N)";
55        cin >> again;
56    }
57
58    system("pause>0");
59
60    return 0;
61}
Moussa
11 Mar 2017
1#include <iostream>
2using namespace std;
3
4int main()
5{
6	int choice;
7
8	cout << 1 << endl;
9	cout << 2 << endl;
10	cout << 3 << endl;
11	cout << 4 << endl;
12
13	cout << "Choice A Number: ";
14	cin >> choice;
15
16	if (choice >= 1 && choice <= 4)
17	{
18		int a, b;
19
20		cout << "Enter Num One: ";
21		cin >> a;
22		cout << "Enter Num Two: ";
23		cin >> b;
24
25		if (choice == 1)
26			cout << a << "+" << b << "=" << a + b << endl;
27		if (choice == 2)
28			cout << a << "-" << b << "=" << a - b << endl;
29		if (choice == 3)
30			cout << a << "*" << b << "=" << a * b << endl;
31	}
32	else
33	{
34		cout << "Wrong Choice" << endl;
35	}
36}
Kelya
15 Sep 2018
1#include <iostream>
2
3using namespace std;
4
5int main()
6{
7int num1;
8int num2;
9char op;
10  
11  cout << "Enter a number:" << endl;
12  cin >> num1; //takes input
13  
14  cout << "Enter another number:" << endl; //prints some prompt
15  cin >> num2;
16  
17  cout << "Enter a operator:" << endl; //prints some prompt
18  cin >> op;
19  
20  if(op == '+')
21  {
22  cout << "Result = " << num1 + num2 << endl;
23  }else if(op == '-'){
24  cout << "Result = " << num1 - num2 << endl;
25  }else if(op == '*'){
26  cout << "Result = " << num1 * num2 << endl;
27  }else if(op == '/'){
28  cout << "Result = " << num1 / num2 << endl;
29  }
30  
31  
32}
queries leading to this page
make calculator in c 2b 2bcpp code for calculatorhow to make calculator in c 2b 2b using switchhow to make calc in cppwrite a program to make simple calculator using switch case in c 2b 2bcalculator c 2b 2b cpdec 2b 2b calculator to codebuild a calculator in c 2b 2bc 2b 2b program to make a simple calculatorc 2b 2b calculatorcalculator on c 2b 2bcalculator c 2b 2b solutionhow to make a c 2b 2b calculator with all operationsbuilding a calculator in c 2b 2bcalculator c 2b 2bsimple calculator program in c 2b 2bhow to make calculator using class in c 2b 2bcalculator cppc 2b 2b simple calculator with classeshow to make a calculator in c 2b 2bcalculation in c 2b 2bcalculator with cppmake a simple calculator in c 2b 2bsource code for calculator in c 2b 2bc 2b 2b program to make a simple calculator using functionscalculator program in cppfunction calculator c 2b 2bcalculator c 2b 2b programmhow to implement calculator c 2b 2bcpp calculatorhow to do calculator in c 2b 2bwrite a program that mimics a calculator c 2b 2bcode c 2b 2b calculatorhow to build a calculator using c 2b 2bsimple calculator using c 2b 2bcalculator code c 2b 2bcalculator in c 2b 2bhow to add a number string to a number in cpp in simple calculatorcalculator in cppdevelop a c 2b 2b program to implement simple calculatororthocenter calculator with stepshow to program a calculator in c 2b 2bcalculator program in c 2b 2b using functions and switch casehow to make a calculator inc 2b 2bhow to make calculator in a program using functions in c 2b 2bc 2b 2b calculator using switch casecode calculator c 2b 2bcalculator program in c 2b 2b using switch casec 2b 2b calculator programc 2b 2b making a calculatorhow to make a simple calculator program in c 2b 2bcrate a calculator in c 2b 2bcalculator using switch c 2b 2bsimple basic calculator c 2b 2bcalculator program in cpp using classsimple calculator c 2b 2bsimple calculater code c 2b 2bbasic calculator c 2b 2bswitch case calculator in c 2b 2bhow to write a calculator in c 2b 2bcalculation module is an example of in c 2b 2bc 2b 2b program to make calculator using switch casec 2b 2b 25 calculationhow do do a calculator in c 2b 2bmaking a simple calculator in c 2b 2bmaking a calculator in c 2b 2bcalculator using switch case c 2b 2bcode for calculator in cpphow to make a basic calculator in c 2b 2bhow to create calculator in c 2b 2bc 2b 2b calculator how to implement divisioncode of calculator in c 2b 2bcalculus in c 2b 2bmaking a calculator c 2b 2bbasic calculator cppc 2b 2b calculator with menuc 2b 2b write a simple calculator using a switch statementc 2b 2b math calculatorhow to make calculator using c 2b 2bc 2b 2b calculator double divisionswitch case calculator in cppscientific calculator program in c 2b 2b using switch casec 2b 2b calculator program advancec 2b 2b program calculatorc 2b 2b calculator scriptmaking a calculator with switch in c 2b 2bcalculator using in cpphow to do a calculator in c 2b 2bhow to implement a calculator c 2b 2bcalculator c 2b 2bc 2b 2b simple calculator using switch casecalculator function c 2b 2bwrite a program to make a calculator using switch case in c 2b 2bturbo c 2b 2b calculator source codec plus plus cal testc 2b 2b calculator programmecalculate cppc 2b 2b code for calculatorhow to make calculator in c 2b 2bsimple calculator c 2b 2b void mainsyntax of switch statement c 2b 2b calculatorc 2b 2b calculator using functions void maincreate a c 2b 2b function the calculatorwrite a c 2b 2b program that performs calculator operations and throws exception if an attempt is made to divide a number by zero or if an invalid operator is applied 2810marks 29 operations allowed 2b 2c 2c 2a 2c 2fcreating a calculator in c 2b 2bsimple c 2b 2b calculator codehow to make a calculator in c 2b 2b using class how to write a calculate in c 2b 2bmake calculator in c 2b 2b to find add 2csub and powercalculator using switch case in cppcalculator using switch and class c 2b 2bcalculator code in c 2b 2bc 2b 2b calculator projecthow to build a calculator in c 2b 2bcalculator in c 2b 2b using functionsc 2b 2b calculator program without using switch casecalc c 2b 2bsimple cpp calculator codewrite a simple calculator program that calculates the difference 2c sum or product of two numbers simple calculator program in c 2b 2b using switch casehow to write a simple calculator program using switch case c 2b 2bc language program for simple calculator enter 1 for addition enter 2 for subtractioncalculator program in c 2b 2bc 2b 2b program to make a simple calculator using switch casec 2b 2b calculator with fuctionsmake calculator using switch operation easy c 2b 2bc 2b 2b switch case calculatorcreate a calculator in c 2b 2bmake a calculator in c 2b 2bcalc calculatorbasic cpp calculatorc 2b 2b calculator using filesyntax of switch statement c 2b 2b calculator functioncalculator in c 2b 2b using switchhow to make a calculator in c 2b 2b using functionshow to build calculator in c 2b 2bwhich coding standard to use to make a calculator c 2b 2bc 2b 2b create a calculatorhow to make simple calculator c 2b 2bsimple calculator using function in c 2b 2bc 2b 2b calculaorcalculator c 2b 2b using functioncalculator with c 2b 2bc 2b 2b calculator program using switch casedesign calculator c 2b 2bsimple c 2b 2b calculatorcpp program of calculatorhow to make simple calculator in c 2b 2bc 2b 2b calculator onlinec 2b 2b calculator logichow to use switch case in c 2b 2b programming for calculatorc 2b 2b calculator functionc 2b 2b calculator codeprogram to make calculator in c 2b 2b using functionoutput calculator c 2b 2bhow to create a calculator in c 2b 2bthe program of simple calculator by switch c 2b 2bc 2b 2b calculator using functionscalculator using only 2b 2bcalculator program using switch case in cppcalculator in c 2b 2b using class2 digitcalculater cpp progrramcode for calculator in cbuild a calculator c 2b 2bcalculator using c 2b 2bc 2b 2b calculator source codemake calculator using switch operation easy oop c 2b 2bc 2b 2b simple calculatorcalcuator program using siwtch case c 2b 2bcalculator using switch case in c 2b 2b gfgcode for a calculator in c 2b 2bc 2b 2b basic calculatorc 2b 2b basic arthimatic calculatorhow to make a calculator with c 2b 2bcalculator c using the switch statement in c 2b 2b to make calculatorc 2b 2b how to make a calculatorcalculator using switch case in c 2b 2bcomplete this simple calculator program using functions c 2b 2bswitch case with c 2b 2b 2c when using calculatorwrite a program to make simple calculator using if else in c 2b 2bhow to write a simple calculator program in cppsimple calculator codezen c 2b 2bc 2b 2b calculator by using functionscpr calculatorhow to make a calculator using function in c 2b 2bcalculator in cpp using switchcalculator in c 2b 2b builderhow to make a calculator in c 2b 2b