Trying to have my Calculator go on infinite loop

The line with For ( It says that h doesn't name a type.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
  #include <iostream>
#include <cstdlib>
using namespace std;

int main ();
int x;
int y;
int x2;
int y2;
int x3;
int y3;
int x4;
int y4;
int n;
int c;
int Mode;
int h;


    for ( int h = 0; h > 10; h=h ) {

	cout << "Welcome to Brian's Calculator!";
	cout << endl;
	cout << "Pick a mode.";
	cout << endl;
 	cout << "1 is Addition.";
 	cout << endl;
 	cout << "2 is Subtraction.";
	cout << endl;
	cout << "3 is Multiplication.";
	cout << endl;
	cout << "4 is Division.";
	cout << endl;
	cout << "5 for Pi!";
	cout << endl;
	cout << "6 to square a number. (n*n)";
	cout << endl;
	cout << "7 to find the circumference of a circle.";
	cout << endl;
 	cout << endl;
	cin >> Mode;
	
	if (Mode==1){
		cout << endl;
	cout << "You chose addition.";
		cout << endl;
   cout << "Pick a number.";
	cout << endl;
	cin >> x;
	cout << endl;
	cout << "Pick another.";
	cout << endl;
	cin >> y;
	cout << endl;
	cout << "The sum of the numbers you chose are: " << x+y <<".";
cin.get();
cin.get();
return 0;	
   }
   
    if (Mode==2){
    	cout << endl;
		cout << "You chose subtraction.";
		cout << endl;
		 cout << "Pick a number.";
	cout << endl;
	cin >> x2;
	cout << endl;
	cout << "Pick another.";
	cout << endl;
	cin >> y2;
	cout << endl;
	cout << "The difference of the numbers you chose are: " << x2-y2 <<".";
cin.get();
cin.get();
	return 0;
	};

 	if (Mode==3){
 		cout << endl;
		cout << "You chose Multiplication.";
		cout << endl;
		 cout << "Pick a number.";
	cout << endl;
	cin >> x3;
	cout << endl;
	cout << "Pick another.";
	cout << endl;
	cin >> y3;
	cout << endl;
	cout << "The product of the numbers you chose are: " << x3*y3 <<".";
cin.get();
cin.get();
	return 0;
	};
	
	 if (Mode==4){
	 	cout << endl;
		cout << "You chose Division.";
		cout << endl;
		 cout << "Pick a number.";
	cout << endl;
	cin >> x4;
	cout << endl;
	cout << "Pick another.";
	cout << endl;
	cin >> y4;
	cout << endl;
	cout << "The quotient of the numbers you chose are: " << x4/y4 <<".";
	cin.get();
cin.get();
	return 0;}
	
	if (Mode==5) {
		cout << endl;
	cout << "Pi is 3.1415926535897932384.";
cin.get();
cin.get();
	}
	
	if (Mode==6) {
		cout << endl;
		cout << "You wished to square a number.";
		cout << endl;
		cout << "Pick a number to square.";
		cout << endl;
		cin >> n;
		cout << endl;
		cout << n << " squared is: " << n * n <<".";
	cin.get();
cin.get();
		return 0;}
		
	if (Mode==7) {
		cout << endl;
		cout << "Enter the diameter of the circle.";
		cout << endl;
		cout << endl;
		cin >> c;
		cout << endl;
		cout << "The circumference is: " << c * 3.14 <<".";
	cin.get();
cin.get();
		return 0;}

		
	

	if (Mode>7) { 
	   cout << endl;
 	   cout << "I'm sorry. I don't understand...";
 	   cout << endl;
 	   cout << "Try again.";
 	   cin.get();
cin.get();
 	   return 0;}
 	   
	}
	} while o >= 0;
	
	return 0;
line 5 - remove the semicolon and add an opening { for the main function.

You only need one return 0 at the end of main.

Edit:

for ( int h = 0; h > 10; h=h )

If h starts at 0, it won't be greater than 10 to run this.

} while o >= 0;

There's a closing while for a do..while loop, but no do.
Last edited on
line 159 should have change into this while( o >= 0)
if you are doing do-while loop you need to have do in line 22 otherwise just parenthesis.

line 5 remove the semicolon (hehe i often put a semicolon on main function too)
you could move the int main() in line 19 if you want the declaration to be global variables
Topic archived. No new replies allowed.