Chapter 2 – Q #16 Diamond Pattern – Tony Gaddis – Starting Out With C++

 

Chapter 2 – Q #16   Diamond Pattern – Tony Gaddis – Starting Out With C++

Diamond Pattern


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


  1. Use only cout statement to print this pattern and use \n for new line.
  2. Use three, two, and one spaces between \n.
  3. Then, use one, two, and three spaces
  4. Return 0 to the main function.

Also, I attach CPP file of this problem. You can download this file

Click Here to Download This File




Thanks!  


Post a Comment

0 Comments