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 :
No comments:
Post a Comment