I am trying to make 3*5 rectangle of # using do.....while statements but I am stuck and i can't go further from here.
Any help would be appreciated. Thanks a lot.
//complier directives
#include<iostream>
using namespace std;
//main body
int main ()
{
//local identifiers
int length,width,Done;
char character,Again;
//input module
cout<<"Please enter the length and width of the rectangle seperated by a space:\n";
cin>>Length>>width;
cout<<"Please enter your design character: \t";
cin>>character;
for(int i=0; i<length; i++)
{
for(int j=0; j<width; j++)
cout<<character;
cout<<endl;
}//end i loop
}
The on problem I see with your program, is you are using a different variable for length. Change it to a lower case 'L' for the input, and your program will work. Also, since main is declared as 'int main()', you should put 'return 0;', before the last parenthesis in your program.
# include <iostream>
usingnamespace std;
int main ()
{
//local identifiers
int length,width;
char character;
//input module
cout << "Please enter the length and width of the rectangle seperated by a space:\n";
cin >> length >> width;
cout << "Please enter your design character: \t";
cin >> character;
int i=0,j=0;
do
{
j=0;
do
{
cout << character;
}while(++j<width);
cout << endl;
}while(++i<length);
return 0;
}