Hi, i just pretty much started taking c++ and our teacher is having us do for...loops. i got the basic concept of it but theres one assignment i do not understand and its driving me crazy and i have the biggest headache.
The assignment was to make a program that asks the users for the length and heightand then it makes a hollow rectangle.. i got the top and bottom horizontal lines and the left vetical line but i can't get the right vetical line
Code:
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
int length;
int height;
cout << "Enter length: ";//user enters the length of the line
cin >> length;
cout << "Enter Height: ";//user enters the height of the line
cin >> height;
cout << endl;
cout << endl;
for (int line = 0; length-1 > line; line += 1){//user enters a number and
//for loop displays a line
cout << "*";// displays the length of the line
}
for (int line = 0; height-2 > length; height +=1){//Could not figure it out
//to make the vertical line on the right side of the rectangle
cout << "*" <<endl;
}
for (int line = 0; height > line; line += 1){ //for loop for height
cout << "*"<< endl;// displays the height .. the endl makes it go to
//the next line
}
for (int line = 0; length > line; line += 1){//user enters a number and for
//loop displays a line
cout << "*";// displays the length of the line
}
cout << endl;
cout << endl;
cout << endl;
system("pause");
}
i don't want anyone to tell me how to do it but give me a hint or some pointers.
thanks
-mike