Question: hi. can you please help me with this problem. its giving me headache since last week Write a program using DO WHILE statement that displays

hi. can you please help me with this problem. its giving me headache since last week

Write a program using DO WHILE statement that displays an inverted equilateral triangle using asterisks. No asterisk should be adjacent to one another. The height will depend on the user input.

[Hint]

You can use an IF statement to eliminate the initial space for the first row.

upon searching the net, i stumble upon this code:

#include #include #include using namespace std;

int main ()

{

cout << "Laboratory Exercises 006 "; cout << "Problem No.3 "; cout << "Sir Markson Francisco ";

//declaration

int a, b; float h; //taking input for height from user

cout<<"Enter the preferred number: ";

cin>> h;

cout<<" ";

a = 1;

do { b = 1; do { if (b > a-1) cout<<"*";

else cout<<" "; b++; //4

} while(b <= h - (a-1)); a++; cout<

} while(a <= (h / 2) + 2);

cout<< endl; return 0;

}

can you please elaborate to me the flow of the process. and why is it when ever im typing an odd number i am getting a good equilateral triangle whereas im having a wrong triangle when ever i typed even number. thank you so much for the help

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!