C++ Program for Printing Stars in Diamond Shape

Program Code:


#include<iostream>
using namespace std;
int main()
{
int a=10 ,b =9 ;
for(int i =1;i<=10;i++)
{
for(int j =1;j<=a;j++)
{
cout<<" ";
}
for(int k=1;k<=i;k++)
{
cout<<"*";
cout<<" ";
}
a--;
cout<<"\n";
}
for(int x =1;x<=9;x++)
{
for(int z = 1;z<=x;z++)
{
cout<<" ";
}
for(int y=1;y<=b;y++)
{
cout<<" ";
cout<<"*";
}
cout<<"\n";
b--;
}
return 0;
}


Output:

.exe file

1 comment:

Please disable your ad blocker to support this website.

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