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
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
Get step-by-step solutions from verified subject matter experts
