I NEED HELP

I have a program due soon and this is the prompt:
Program 6
Filled Squares
Write a program that will require the user to enter an ODD integer between 0 and 20. The program will
then output to a file a square made of characters that has the same height and width as the odd number
entered at the console.
The characters that form the outside of the square will be ‘2’. The single
character that is located in the very center of the square will be ‘*’. All the rest of the interior characters
of the square will be ‘0‘ (character zeros).
For example if the user enters the odd number 7 the file output would look like the figure below.
2222222
2000002
2000002
200*002
2000002
2000002
2222222
The print characters should be implemented as named constants. The user should continue to be prompted until an odd number in the correct range has been entered. The creation of the output file should be verified.


I think I can use an array to do this. But I do not know the outline of how it should look. Thanks
IN fact, this is excercise on for loops. Just make two nested for loops from 0 to nymber entered.
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
int main()
{
	int number,
	    number_2,
		number_0;


	cout << "Enter the an odd number between 0-20." << endl;
	cin >> number;

if (number%2 =1)
{
	cin >> number;
	for (int j = number; j >0; j--)
	{
	   number_2 = 2;
	   number_0 = 0;
	   for ( )
	   {
		   cout << number_2;
	   }


       number = number -1;
	}
}
else
{
	cout << "Invalid input." << endl;
	cout << "Enter the an odd number between 0-20." << endl;
		cin >> number;
}
	return 0;
}



I know this isn't correct but am I on the right track?
Yes, you on the right track.
Line 13: You already got number and validated it.
I probably would make validation in a different way:
1
2
3
4
5
6
std::cin >> number;
while((number % 2 != 1) && (number < 20) && (number > 0) {
    std::cout << "Invalid input.\nEnter an odd number between 0-20: "
    std::cin >> number;
}
//for... 
Topic archived. No new replies allowed.