I am stuck and mega confused

I am trying to write a program that uses a user defined function. It will prompt the user to enter a valid height and valid width. After these two numbers are validated, it will then print a row of x's ( with height being how many rows pring, and with being the number of x's within each row.)

For example:
Height: 3
width: 6

output:
xxxxxx
xxxxxx
xxxxxx

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
  #include <iostream>

using namespace std;

void box(int);

int main()
{
	int h, w;
	box(2);

	cout << "Enter height (0-25): " << endl;
		cin >> h;

	cout << "Enter width (0-25): " << endl;
		cin >> w;

		if (h < 0 || h > 25 || w < 0 || w > 25){
			cout << "invalid number";
			cout << "Please enter a number between 0 and 25: " << endl;
		}

		else if  (h > 0 && h < 25 && w > 0 && w < 25){
			for (int x = 1; x <= h; x += h) {
				cout << "X" << x << endl;
			}
			for (int y = 1; y <= w; y += w) {
				cout << "X" << y << endl;
			}
				

			}

		else if(){
			cout << "Please enter a number between 0 and 25: " << endl;
		}

		cout << "Exiting..." << endl;
		return 0;
		
}


Error messages include:

Error 2 error C2059: syntax error : ')' c:\users\nicole\documents\visual studio 2013\projects\consoleapplication3\consoleapplication3\source.cpp 30 1 ConsoleApplication3
Error 3 error C2143: syntax error : missing ';' before '{' c:\users\nicole\documents\visual studio 2013\projects\consoleapplication3\consoleapplication3\source.cpp 30 1 ConsoleApplication3
Error 4 error C1075: end of file found before the left brace '{' at 'c:\users\nicole\documents\visual studio 2013\projects\consoleapplication3\consoleapplication3\source.cpp(8)' was matched c:\users\nicole\documents\visual studio 2013\projects\consoleapplication3\consoleapplication3\source.cpp 38 1 ConsoleApplication3
5 IntelliSense: expected an expression c:\Users\Nicole\Documents\Visual Studio 2013\Projects\ConsoleApplication3\ConsoleApplication3\Source.cpp 34 11 ConsoleApplication3
The for loops on 24 and 27 are all kinds of messed up. Try and work out the logic of what they're doing.

Line 34 should be else {
closed account (48T7M4Gy)
1
2
3
4
5
6
7
8
9
	
for (int x = 1; x <= h; x ++)
		{
			{
				for (int y = 1; y <= w; y ++)
				cout << "X" ;
		        }
				cout << endl;
		}


delete the reference to box[2]

Try starting with getting it running properly without the error checking else's and if's and maybe use a while statement once you solve the X's displaying properly.
Topic archived. No new replies allowed.