Chapter 2 – Q #15 Triangle Pattern – Tony Gaddis – Starting Out With C++
Problem: -
Write a program that displays the following pattern on the screen:
*
***
*****
*******
Solution: -
#include <iostream>
using namespace std;
int main()
{
cout << " *\n ***\n *****\n*******";
return 0;
}
This is the solution of this question
OUTPUT OF THIS QUESTION
Explanation of this Solution
- Use only cout statement to print this pattern and use \n for new line.
- Use three, two, and one spaces between \n.
- Return 0 to the main function.
Also, I attach CPP file of this problem. You can download this file
0 Comments