#include <string.h>
#include <iostream.h>
#include <conio.h>int main()
{
int i, j, k;
int n = 0;
cout<<"Program for displaying pattern of *.\n";
cout<<"Enter the maximum number of *: ";
cin>>n;
cout<<"\nHere is the Diamond of Stars\n";
for (i = 1; i <= n; i++)
{
for (j = 0; j < (n - i); j++)
cout<<" ";
for (j = 1; j <= i; j++)
cout<<"*";
for (k = 1; k < i; k++)
cout<<"*";
cout<<"\n";
}
for (i = n - 1; i >= 1; i--)
{
for (j = 0; j < (n - i); j++)
cout<<" ";
for (j = 1; j <= i; j++)
cout<<"*";
for (k = 1; k < i; k++)
cout<<"*";
cout<<"\n";
}
cout<<"\n";
getch();
return 0;}
#include <iostream.h>
#include <conio.h>int main()
{
int i, j, k;
int n = 0;
cout<<"Program for displaying pattern of *.\n";
cout<<"Enter the maximum number of *: ";
cin>>n;
cout<<"\nHere is the Diamond of Stars\n";
for (i = 1; i <= n; i++)
{
for (j = 0; j < (n - i); j++)
cout<<" ";
for (j = 1; j <= i; j++)
cout<<"*";
for (k = 1; k < i; k++)
cout<<"*";
cout<<"\n";
}
for (i = n - 1; i >= 1; i--)
{
for (j = 0; j < (n - i); j++)
cout<<" ";
for (j = 1; j <= i; j++)
cout<<"*";
for (k = 1; k < i; k++)
cout<<"*";
cout<<"\n";
}
cout<<"\n";
getch();
return 0;}
No comments:
Post a Comment