Trending This Week:

test

Post Top Ad

Your Ad Spot

Tuesday, June 21, 2022

C++ Program to print triangle which is empty from inside.

       




C++ Program to print triangle which is empty from inside.


#include <iostream>
using namespace std;
int main ()
{
    int n,i,j;
    cout<<"Enter Number: ";
    cin>>n;
    
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=i;j++)
        {
            if(j==i || j==1 || i==n)
                cout<<"*";
            else
                cout<<" ";
        }    
        cout<<endl;
    }

    return 0;
}

Output :




Hash Tags:

#CPP #Calculation #SumOfTwoNumbers #Plus #Programming #coding #Addition #Code #SourceCode #java #CLanguage #Python #Logical #Maths #pattern




No comments:

Post a Comment

Post Top Ad

Your Ad Spot