06-05-2011, 03:45 PM
|
| Never Give Up | | Join Date: Jan 2011 Location: SahiwaL Age: 31
Posts: 26
Program / Discipline: BSIT Class Roll Number: 10-26 | |
A Program that makes a Diamond Pattern Stars in the output. #include<iostream.h>
#include<conio.h>
void main()
{ int a,b,c,i,j,k,n; clrscr(); cout<<"enter the value of n\n"; cin>>n; //for the first half of diamond for(i=n;i>0;i--)
{
for(j=1;j<i;j++)
{
cout<<" ";
}
for(k=j-1;k<n;k++)
{
cout"*";
cout<<" ";
}
cout<<"\n";
} //for the second half of diamond for(a=n-1;a<n&&a!=-1;a--)
{
for(b=n;b>a;b--)
{
cout<<" ";
}
for(c=0;c<a;c++)
{
cout<<"*";
cout<<" ";
}
cout<<"\n";
} getch(); } |