Chapter 2 – Q #16 Diamond Pattern – Tony Gaddis – Starting Out With C++
Problem: -
Write a program that displays the following pattern:
*
***
*****
*******
*****
***
*
Solution: -
#include <iostream>
using namespace std;
int main()
{
cout << " *\n ***\n *****\n*******
<<\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.
- Then, use one, two, and three spaces
- Return 0 to the main function.
Also, I attach CPP file of this problem. You can download this file
0 Comments