c 2b 2b calculator

Solutions on MaxInterview for c 2b 2b calculator by the best coders in the world

showing results for - "c 2b 2b calculator"
Viktoria
23 Jan 2016
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}
María Fernanda
20 Jun 2019
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
Samantha
30 Apr 2018
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}
Jessica
16 May 2017
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}
Angela
20 Nov 2017
1#include <iostream>
2
3using namespace std;
4
5int main()
6{
7cout << "Welcome to the Calculator, write :cancel: to cancel the calculator\n";
8 string cancel;
9
10 while(cancel != "cancel")
11 {
12     int number1 = 0;
13     int number2 = 0;
14     string op;
15
16     cout << "please enter your first number!\n";
17
18     cin >> number1;
19
20     cout << "please enter your second number!\n";
21
22     cin >> number2; 
23
24     cout << "please enter a operator!\n";
25     cout << "( *, / , + , - )";
26
27     cin >> op;
28    
29    if(op == "*")
30    {
31        number1 = number1 * number2;
32        cout << number1; 
33        number1 = 0;
34        number2 = 0;
35    }
36
37    if(op == "/")
38    {
39        number1 = number1 / number2;
40        cout << number1;
41        number1 = 0;
42        number2 = 0;
43    }
44
45    if(op == "+")
46    {
47        number1 = number1 + number2; 
48        cout << number1;
49        number1 = 0;
50        number2 = 0;
51    }
52
53    if(op == "-")
54    {
55        number1 = number1 - number2;
56        cout << number1; 
57        number1 = 0; 
58        number2 = 0;
59    }
60    
61    cout << "Write cancel to cancel\n";
62    cout << "write continue to resume with the calculator!\n";
63    
64    cin >> cancel;
65
66 }
67  
68  
69}
70//powered by my coding server: https://discord.gg/GUgnYHJV
Yannik
28 May 2018
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}
queries leading to this page
c 2b 2b math calculatormaking a calculator with switch in c 2b 2bc language program for simple calculator enter 1 for addition enter 2 for subtractionsimple calculater code c 2b 2bc 2b 2b simple calculator using switch casecalc calculatorcalculator c c 2b 2b calculaorcalculator with cppprogram to make calculator in c 2b 2b using functionturbo c 2b 2b calculator source codesimple calculator program in c 2b 2bc 2b 2b calculator program using switch casec 2b 2b calculator by using functionscalc c 2b 2bc 2b 2b calculator onlinec 2b 2b calculator with menucalculator on c 2b 2bc 2b 2b calculator scriptcomplete this simple calculator program using functions c 2b 2bcalculator code in c 2b 2bcpp code for calculatormake calculator using switch operation easy oop c 2b 2bhow to implement a calculator c 2b 2bhow to do a calculator in c 2b 2bsimple calculator c 2b 2b void mainc 2b 2b simple calculatorwrite a program to make simple calculator using if else in c 2b 2b2 digitcalculater cpp progrramhow to add a number string to a number in cpp in simple calculatorhow to make calculator using c 2b 2bswitch case with c 2b 2b 2c when using calculatorsimple cpp calculator codehow to make calculator in c 2b 2b using switchbasic cpp calculatorhow to make calc in cpphow to make a basic calculator in c 2b 2bfunction calculator c 2b 2bc 2b 2b calculator program without using switch casec 2b 2b making a calculatorcalculator in c 2b 2b using functionsc 2b 2b simple calculator with classesc 2b 2b how to make a calculatorsource code for calculator in c 2b 2bmake calculator using switch operation easy c 2b 2bcpp program of calculatorcalculator in c 2b 2b using classhow to make simple calculator in c 2b 2bwrite 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 2fcalculator program in cpphow to write a calculate in c 2b 2bcreate a calculator using the switch statement c 2b 2bmake calculator in c 2b 2b to find add 2csub and powermake a simple calculator in c 2b 2bcalculator c 2b 2b programmsimple calculator program in c 2b 2b using switch casec 2b 2b calculator double divisionwhich coding standard to use to make a calculator c 2b 2bwrite a program that mimics a calculator c 2b 2bwrite a simple calculator program that calculates the difference 2c sum or product of two numbers c 2b 2b program to make a simple calculator using switch casec 2b 2b create a calculatorcalculate cpphow to create calculator in c 2b 2bhow to make calculator in c 2b 2bc 2b 2b calculator programmecalculator in cpp using switchcalculator c 2b 2b cpdecrate a calculator in c 2b 2bmaking a calculator in c 2b 2bmaking a simple calculator in c 2b 2bc 2b 2b calculator to codeprogram to build a simple calculator using switch statement c 2b 2bc 2b 2b calculator using switch casecode for calculator in cc plus plus cal testc 2b 2b program to make a simple calculator using functionscalculator using in cppc 2b 2b program to make a simple calculatorcalculator program in cpp using classhow to build a calculator in c 2b 2bhow to program a calculator in c 2b 2bbasic calculator c 2b 2bhow to do calculator in c 2b 2bc 2b 2b calculatorcalculator using switch c 2b 2bwrite a program to make simple calculator using switch case in c 2b 2bcalculator program in c 2b 2b using switch casecalculator using switch case in c 2b 2bmaking a calculator c 2b 2bc 2b 2b basic arthimatic calculatorcalculation module is an example of in c 2b 2bsimple calculator codezen c 2b 2bsimple basic calculator c 2b 2bcalculator c 2b 2b solutionc 2b 2b basic calculatorcalculator program using switch case in cppcalculator c 2b 2bcode c 2b 2b calculatorhow to implement calculator c 2b 2bbuilding a calculator in c 2b 2bcalculator c 2b 2b using functionc 2b 2b calculator logicc 2b 2b calculator using filesimple calculator using c 2b 2bc 2b 2b calculator source codecalculator using switch case in c 2b 2b gfgcreate a c 2b 2b function the calculatorcreating a calculator in c 2b 2bcalculation in c 2b 2bc 2b 2b 25 calculationhow to make a calculator in c 2b 2bcalculator with c 2b 2bhow to make a calculator in c 2b 2b using class using the switch statement in c 2b 2b to make calculatorcalculator program in c 2b 2bcontunuse calculator in c 2b 2bc 2b 2b calculator program advancec 2b 2b write a simple calculator using a switch statementsimple calculator c 2b 2bcalculator using only 2b 2bcalculator in c 2b 2b using switchcode of calculator in c 2b 2bsimple c 2b 2b calculatorhow to write a calculator in c 2b 2bswitch case in c 2b 2b calculatorcalculator code c 2b 2bcode for a calculator in c 2b 2bhow to create a calculator in c 2b 2bcalculator c 2b 2bbuild a calculator c 2b 2bhow to write a simple calculator program in cppc 2b 2b switch case calculatorcalculator in c 2b 2b buildercalculator function c 2b 2bhow to make simple calculator c 2b 2bcode calculator c 2b 2bwrite a program to make a calculator using switch case in c 2b 2bc 2b 2b program calculatorc 2b 2b calculator using functions void mainhow to make a calculator inc 2b 2bcode for calculator in cppsimple calculator using function in c 2b 2bcpp calculatorc 2b 2b calculator how to implement divisioncalculator in cppswitch case calculator in cppcalculus in c 2b 2bcalculator using c 2b 2bc 2b 2b calculator functionhow to make a calculator using function in c 2b 2bmake calculator in c 2b 2bhow to make calculator in a program using functions in c 2b 2bbuild a calculator in c 2b 2bhow do do a calculator in c 2b 2bcalculator using switch case c 2b 2bbasic calculator cpphow to build calculator in c 2b 2boutput calculator c 2b 2bc 2b 2b calculator projectdesign calculator c 2b 2bmake a calculator in c 2b 2bc 2b 2b calculator with fuctionscalculator in c 2b 2borthocenter calculator with stepssyntax of switch statement c 2b 2b calculatorcalculator using switch and class c 2b 2bcalcuator program using siwtch case c 2b 2bc 2b 2b calculator programcalculator program in c 2b 2b using functions and switch casec 2b 2b calculator using functionshow to make a calculator with c 2b 2bhow to make calculator using class in c 2b 2bhow to write a simple calculator program using switch case c 2b 2bhow to use switch case in c 2b 2b programming for calculatorswitch case calculator in c 2b 2bthe program of simple calculator by switch c 2b 2bhow to make a c 2b 2b calculator with all operationscpr calculatorc 2b 2b calculator codecalculator cppcalculator using switch case in cppc 2b 2b code for calculatorhow to make a calculator in c 2b 2b using functionssimple c 2b 2b calculator codesyntax of switch statement c 2b 2b calculator functioncreate a calculator in c 2b 2bc 2b 2b program to make calculator using switch casescientific calculator program in c 2b 2b using switch casec 2b 2b calculator