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 7Explanation / 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();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.