Consider the program below that prints a triangle of characters (see an example
ID: 3545544 • Letter: C
Question
Consider the program below that prints a triangle of characters (see an example below). The program asks the user for the size and character to draw the triangle. The code below has several errors; find them, determine their types, and correct them.
#include<iostream> using namespace std;
int main() {
}
char TriangleChar; int size;
cout<<"Please enter a character to draw a triangle: "; cin>> TriangleChar;
cout<<" Please determine the size of the triangle: "; cin>>Size;
while(int i=0; i<Size; i++) {
for(int j=Size-i; j>0; j++); cout<<" ";
for(int k=1, k<=(2*i+1), k++) cout<<"*";
cout<<endl;
cout<<" The values of iterators i,j,and k respectively: "<< i , j , k ;
system ("Pause"); return 0;
Explanation / Answer
#include<iostream>
using namespace std;
int main()
{
char TriangleChar;
int size,i,k,j;
cout<<"Please enter a character to draw a triangle:";
cin>> TriangleChar;
cout<<" Please determine the size of the triangle: ";
cin>>size;
for(int i=0; i<size;i++)
for(int j=size-
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.