Friday, February 13, 2015

C program to print the following pattern


C++ program to print the following pattern:

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr(); //to clear the screen
int i,j,k,n;
cout<<"How many lines?";
cin>>n;
n*=2;

for(i=0;i<n;i+=2)
{
cout<<"
";

for(j=n;j>i;j-=2)
cout<<" ";
for(k=0;k<=i;++k)
cout<<"*";
}
getch(); //to stop the screen
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.