Sunday, 7 February 2016

Write a C++ program to draw isosceles triangle using counting 54321

Leave a Comment
Questions:

Write a C++ program to draw isosceles triangle using counting 54321 in reverse order

Explanation:

This C++ Program is example of nested loop.Below mention code is compiled in Visual Studio 2015 and output snap is attached.. If any problem you feel and want explanation feel free to contact.
Code:

/**************************************************|
/*************C++ Programs And Projects************|

***************************************************/

#include<iostream>
using namespace std;
void main() {
       int value;
       cout << "Enter the size = ";
       cin >> value;
       int space = value;
       for (int i = 0; i < value; i++) {
              for (int j = space; j > 0; j--) {
                     cout << " ";
              }
              for (int star = i * 2; star >= 0; star--) {
                     cout << star + 1;
              }
              space--;
              cout << endl;
       }

}


Output:
Write a C++ program to draw isosceles triangle using counting 54321


Related Articles:

C++ Shapes Codes
If You Enjoyed This, Take 5 Seconds To Share It

0 Questions: