calculator with c 2b 2b

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

showing results for - "calculator with c 2b 2b"
María Fernanda
25 Sep 2019
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}
Juan Diego
12 Feb 2020
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
Jordan
18 Feb 2020
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}
Annaelle
14 Jan 2016
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
cpp code for calculatorhow to make calc in cppcalculator c 2b 2b cpdec 2b 2b calculator to codebuild a calculator in c 2b 2bc 2b 2b calculatorcalculator on c 2b 2bcalculator c 2b 2b solutionbuilding a calculator 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 2bcalculator with cppmake a simple calculator in c 2b 2bfunction calculator c 2b 2bcpp calculatorhow to do calculator in 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 2bcalculator in cppdevelop a c 2b 2b program to implement simple calculatorhow to program a calculator in c 2b 2bhow to make calculator in a program using functions in c 2b 2bcode calculator c 2b 2bc 2b 2b calculator programc 2b 2b making a calculatorhow to make a simple calculator program in c 2b 2bcrate a calculator in c 2b 2bsimple calculator c 2b 2bcalculator program in cpp using classbasic calculator c 2b 2bcalculation module is an example of in c 2b 2bhow do do a calculator in c 2b 2bmaking a simple calculator in c 2b 2bmaking a calculator in c 2b 2bcode for calculator in cpphow to make a basic calculator in c 2b 2bhow to create calculator in c 2b 2bcode 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 calculatorc 2b 2b calculator program advancec 2b 2b program calculatorc 2b 2b calculator scripthow to do a calculator in c 2b 2bhow to implement a calculator c 2b 2bcalculator c 2b 2bcalculator function c 2b 2bc 2b 2b calculator programmec 2b 2b code for calculatorhow to make calculator in c 2b 2bcreate a c 2b 2b function the calculatorsimple c 2b 2b calculator codehow to make a calculator in c 2b 2b using class how to write a calculate in 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 functionssimple cpp calculator codecalculator program in c 2b 2bcontunuse calculator in c 2b 2bmake a calculator in c 2b 2bcreate a calculator in c 2b 2bc 2b 2b calculator using filehow 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 2bsimple c 2b 2b calculatorcpp program of calculatorhow to make simple calculator in c 2b 2bc 2b 2b calculator logicc 2b 2b calculator codeprogram to make calculator in c 2b 2b using functionhow to create a calculator in c 2b 2bc 2b 2b calculator using functionscalculator 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 codec 2b 2b simple calculatorc 2b 2b basic calculatorhow to make a calculator with c 2b 2bc 2b 2b how to make a calculatorc 2b 2b calculator by using functionscpr calculatorhow to make a calculator using function in c 2b 2bcalculator in c 2b 2b buildercalculator with c 2b 2b