i created a program where you input a height and width and the output is a rectangle of asterisks. and when a negative height or width or both is entered, the number changes to one, but the output screen is just black, can someone help me with this.
Code:
#include <iostream>
using namespace std;
int height;
int width;
int tmp;
int tmp2;
int main(){
cout<<"Enter height rectangle: ";
cin>>height;
if(height < 1)
height = 1;
else
if(height > 20)
height = 20;
cout<<"Enter width rectangle: ";
cin>>width;
if(width < 1)
width = 1;
else
if(width > 20)
width = 20;
for(tmp = 0; tmp != width; tmp++)
cout<<"*";
for(tmp = 2; tmp != (height ); ++tmp){
cout<<"\n*";
for(tmp2 = 2; tmp2 != (width); ++tmp2)
cout<<" ";
cout<<"*";
}
cout << "\n*";
for(tmp = 1; tmp != (width); ++tmp)
cout<<"*";
cout<<"\n";
cout<<height<<endl;
cout<<width<<endl;
system("pause");
return 0;
}