Respuesta :
Answer:
The above program is not correct, the correct program in c++ langauge is as follows:
#include <iostream>//header file.
using namespace std; //package name.
int main() //main function.
{
char char_input;//variable to take charater.
int size,i,j;//variable to take size.
cout<<"Enter the size and charter to print the traingle: ";//user message.
cin>>size>>char_input; //take input from the user.
for(i=0;i<size;i++)//first for loop.
{
for(j=0;j<=i;j++)//second for loop to print the series.
cout<<char_input<<" ";//print the charater.
cout<<"\n";//change the line.
}
return 0; //returned statement.
}
Output:
- If the user inputs 5 for the size and '%' for the charater, then it will prints the above series example.
Explanation:
- The above program is written in C++ language, in which there are two for loop which prints the series.
- The first for loop runs n time, where n is the size given by the user.
- The second loop is run for every iteration value of the first for loop.
- For example, if the first for loop runs for the 2 times, then the second for loop runs 1 time for the first iteration of the first loop and 2 times for the second iteration of the first loop.