C++ Program Code for Printing Stars in Arrow Shape

Program Code:

#include<iostream>
using namespace std;
int main()
{
for(int i=1;i<5;i++){
for(int j=0;j<3;j++)
cout<<" ";
for(int k=1;k<=i;k++)
{
cout<<"*";
}
cout<<"\n";
    }
    
    for(int m=5;m>0;m--)
    {
    for(int n=0;n<3;n++)
    cout<<" ";
    for(int l=0;l<m;l++)
{
cout<<"*";
}
cout<<"\n";
    }

return 0;
}

Output:

.exe file

No comments:

Post a Comment

Please disable your ad blocker to support this website.

Our website relies on revenue from ads to keep providing free content.