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

Write a program that prints isosceles triangles using the character \'*\'. The n

ID: 3623288 • Letter: W

Question

Write a program that prints isosceles triangles using the character '*'. The number of
rows forming the triangle is determined by the user. For instance, an isosceles triangle with
five rows looks like:
*
***
*****
*******
*********



My failed code so far is this:

#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main()
{

int n; // Number of rows declared by the user
int i; // Counting variable for number of rows
char star('*'); // Character for triangle
char blank(' '); // Spaces for uniformity



cout << "Enter number of rows: "; // Prompt for entering rows
cin >> n;

// User must enter at least 2

while (n<2)
{
cout << "Number of rows must be at least 2 " << endl;

cout << "Enter number of rows: ";
cin >> n;

}

for (i=2; i<=n; i=i+1)
{


cout << setfill(blank) << setw(n) << blank;

cout << setfill(star) << setw(i*2-1) << star;

cout << blank << endl;

}






return(0);
}


Explanation / Answer

int main(int argc, char *argv[]) { int height = -1; while (height height; } int num_of_pluses = 1; for (int i = 0; i
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