Answer to Question #160947 in C++ for Rohit Rawat

Question #160947

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).


repeat(2){

repeat(2){

B1;

left(B3);

B1;

left(120);

}

right(120);

penUp();

B2;

penDown();

repeat(2){

B1;

left(120);

B1;

left(B3);

}

right(B3);

penUp();

B2;

penDown();

}


What is command B1?


forward(100)

 

forward(20)

 

backward(100)

 

backward(20)


What is command B2?


forward(100)

 

forward(20)

 

backward(100)

 

backward(20)

What is B3?



1
Expert's answer
2021-02-03T11:17:56-0500
#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;
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment