View Single Post
  #1  
Old 06-05-2011, 03:45 PM
JuNaiDiQbaL's Avatar
JuNaiDiQbaL JuNaiDiQbaL is offline
Never Give Up

 
Join Date: Jan 2011
Location: SahiwaL
Age: 31
Posts: 26
Program / Discipline: BSIT
Class Roll Number: 10-26
JuNaiDiQbaL has a spectacular aura aboutJuNaiDiQbaL has a spectacular aura about
Default 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();
}
Reply With Quote