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}
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
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}
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}
1/*THIS CALCULATOR WORKS ON THE FORMULA OF DMAS WHICH MEANS DIVIDE , MULTIPLY ,
2ADDITION , SUBTRACTION BUT IT IS 1234 1=DIVIDE,2=MULTIPLY,3=ADDITION,
34=SUBTRACTION WE HAVE TO WRITE THEM
4IN THE OPERATOR */
5#include <iostream>
6using namespace std;
7int main ()
8{
9 int x;
10 int opera;
11 int y;
12 /* cout<<"MADE ENTIREY BY AADITYA BK"<<endl; */
13 cout<<"enter the first num"<<endl;
14 cin>>x;
15 cout<<"enter the operator"<<endl;
16 cin>>opera;
17 cout<<"enter the second num"<<endl;
18 cin>>y;
19 if (opera<4)
20 {
21 cout<<"= "<<(x+y)<<endl;
22 }
23 else
24 {
25 return 0;
26 }
27 return 0;
28 if (opera<5)
29 {
30 cout<<"= "<<(x-y)<<endl;
31 }
32 else
33 {
34 return 0;
35 }
36 return 0;
37 if (opera<2)
38 {
39 cout<<"= "<<(x/y)<<endl;
40 }
41 else
42 {
43 return 0;
44 }
45 return 0;
46 if (opera<3)
47 {
48 cout<<"= "<<(x*y)<<endl;
49 }
50 else
51 {
52 return 0;
53 }
54 int sucessed=10;
55 return sucessed;
56}
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}