Fill in the blanks in the following code. The code is written to draw 4 rectangles of heights 20, 30, 40, 50 respectively and widths 20, 15, 10, 5 respectively. The centres of these rectangles are at (1,2)
initCanvas();
double x=20;
double y=20;
repeat(4){
Rectangle r( BLANK-P , BLANK-Q , x, y);
r.imprint();
x = x + BLANK-R ;
y = y + BLANK-S ;
}
What is BLANK-P ?
What is BLANK-Q ?
What is BLANK-R ?
What is BLANK-S ?
#include <iostream>
using namespace std;
int main () {
// rectangles of heights 20, 30, 40, 50 respectively and widths 20, 15, 10, 5 respectively
cout << "1 - rectangle height = 20, width = 20\n";
for (int i = 0; i < 20; i++) {
for (int j = 0; j < 20; j++) {
cout << "# ";
}
cout << endl;
}
cout << "\n\n2 - rectangle height = 30, width = 15\n";
for (int i = 0; i < 30; i++) {
for (int j = 0; j < 15; j++) {
cout << "# ";
}
cout << endl;
}
cout << "\n\n3 - rectangle height = 40, width = 10\n";
for (int i = 0; i < 30; i++) {
for (int j = 0; j < 10; j++) {
cout << "# ";
}
cout << endl;
}
cout << "\n\n4 - rectangle height = 50, width = 5\n";
for (int i = 0; i < 30; i++) {
for (int j = 0; j < 5; j++) {
cout << "# ";
}
cout << endl;
}
}
Comments
Leave a comment