1
1111111111
I am writing a program that tells users to enter 2 sides of a
rectangle. From that the program will output a drwaing of the
rectangle using "*"'s... Here is my problem. Say I enter 5 and 10 for
the 2 sides.. This is what is output.
********** *
* *
* *
* *
**********
I dont know why it is adding that asterk on the first row.. Same
thing happens if I enter 2 other sides. Etc... Any help would be
appriciated!!!
Here is my code so far: I use Turbo hence the .h
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
int main()
{
clrscr();
int side1, side2;
cout<<"Please enter side 1: ";
cin>>side1;
cout<<"Please enter side 2: ";
cin>>side2;
for(int a=1; a<side1; a++)
cout<<"*";
for(int b=1; b<=(side2-1); b++)
cout<<"*"<<setw(side1-1)<<"*"<<endl;
for(int c=1; c<=side1; c++)
cout<<"*";
return 0;
}
rectangle. From that the program will output a drwaing of the
rectangle using "*"'s... Here is my problem. Say I enter 5 and 10 for
the 2 sides.. This is what is output.
********** *
* *
* *
* *
**********
I dont know why it is adding that asterk on the first row.. Same
thing happens if I enter 2 other sides. Etc... Any help would be
appriciated!!!
Here is my code so far: I use Turbo hence the .h
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
int main()
{
clrscr();
int side1, side2;
cout<<"Please enter side 1: ";
cin>>side1;
cout<<"Please enter side 2: ";
cin>>side2;
for(int a=1; a<side1; a++)
cout<<"*";
for(int b=1; b<=(side2-1); b++)
cout<<"*"<<setw(side1-1)<<"*"<<endl;
for(int c=1; c<=side1; c++)
cout<<"*";
return 0;
}