(iii) Write a function void rectangle(int w, int h) to print an open rectangle of asterisks (*). The parameters w and h are the width and the height of the rectangle, expressed in number of asterisks
1
Expert's answer
2022-05-25T10:23:29-0400
#include<iostream>usingnamespace std;
voidrectangle(int w, int h){
int i, j;
for(i=0;i<h;i++) {
for(j=0;j<w;j++) {
cout<< "*" <<' ';
}
cout<<endl;
}
}
intmain(){
int width, height;
cout<<"Enter width: ";
cin>>width;
cout<<"Enter height: ";
cin>>height;
rectangle(width, height);
return0;
}
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments