Fill in the blanks in the following program so that it draws the given picture. Each
figure is a rhombus with side 100 and interior angles (60, 120, 60, 120). The distance
between 2 adjacent rhombuses is 20 (between their closest vertices).
#include <iostream>
#include <conio.h>
using namespace std;
int main() {
int i, j, rows;
char ch;
cout << "Enter the number of rows\n";
cin >> rows;
cout << "Enter the Symbol for pattern\n";
cin >> ch;
cout<<"\n";
i=1;
while(i <= rows) {
//outer while loop
j = 1;
while(j <= rows - i) {
//inner while loop
cout << " ";
//print space
j++;
}
j = 1;
while(j <= rows){
//inner while loop
cout << ch;
//print character after space
j++;
}
cout << "\n";
//move to next line
i++;
}
getch();
return 0;
}
Comments
Leave a comment