Nov 21, 2017 Zeshan Mumtaz

C++ Draw An Isosceles Triangle Using Nested For Loop
4   1   52   Programming - C++

Facebook   Twitter   Google   Email
post-img
 

Introduction

Write a program which draw isosceles Triangle Shape with asterisk(*) and using nested for loop


Isosceles Triangle Using Nested for Loop

#include<iostream>
using namespace std;
int main()
{
    
    for(int a = 1; a <= 9; a=a+2)
    {
        for(int b = 9; b >= a; b=b-2)
        {
            cout<<" "; // Print White Spaces
        }
        for(int c = 1; c <=a; c++)
        {
            cout<<"*"; // Print Asterisk sign
        }
        cout<<endl; // new line
    }
}
// Posted on GoIT.pk

Output

         *
        * * *
      * * * * *
    * * * * * * *
  * * * * * * * * *


Is this helpful?   Yes   No

Facebook   Twitter   Google   Email
Click to copy
Successfully copy the link to share

Leave a Comment


Comments (1)


Thank you for your feedback
You are now following
Request Sent! Wait for Approval
Removed From Following
Something wents wrong!
Thank you for your comment