Chapter 2 – Q #15 Triangle Pattern – Tony Gaddis – Starting Out With C++

Chapter 2 – Q #15  Triangle Pattern – Tony Gaddis – Starting Out With C++


Triangle Pattern

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


  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. 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