Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ please! (3) Use a nested loop to draw the triangle. The first line will only

ID: 3789384 • Letter: C

Question

C++ please!

(3) Use a nested loop to draw the triangle. The first line will only have one character but will now need to output enough spaces such that the character is output at the end of the row instead of the beginning. The number of characters on each line will increase by one until you have reached the base of your triangle. Include spaces between each character.

(3) Use a nested loop to draw the triangle. The first line will only have one character but will now need to output enough spaces such that the character is output at the end of the row instead of the beginning. The number of characters on each line will increase by one until you have reached the base of your triangle. Include spaces between each character. Ex. Enter a character Enter number of rows 7

Explanation / Answer

#include<iostream.h>
#include<conio.h>

void main()
{
int i, j, k,num;
cout << "enter number of rows: ";
cin >> num;


for(i=num;i>=1;i--)
{
for(j=1;j<i;j++)
{
cout<<" ";
}
for(k=num;k>=i;k--)
{
cout<<"*";
}
cout<<" ";
}
getch();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote