PROGRAM ON PATTERN 1
*
* *
* *
* *
* *
* *
* *
* *
* *
**********
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void main()
{
int i,j,n;
clrscr();
cout<<"Enter the value of n:";
cin>>n;
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
cout<<" ";
}
for(j=1;j<=i;j++)
{
if(j==1||i==n)
{
cout<<"*";
}
else
{
cout<<" ";
}
for(j=1;j<i;j++)
{
if(j==i-1||i==n
)
{
cout<<"*";
}
else
{
cout<<" ";
}
}
cout<<"\n";
}
}
getch();
}
* *
* *
* *
* *
* *
* *
* *
* *
**********
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void main()
{
int i,j,n;
clrscr();
cout<<"Enter the value of n:";
cin>>n;
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
cout<<" ";
}
for(j=1;j<=i;j++)
{
if(j==1||i==n)
{
cout<<"*";
}
else
{
cout<<" ";
}
for(j=1;j<i;j++)
{
if(j==i-1||i==n
)
{
cout<<"*";
}
else
{
cout<<" ";
}
}
cout<<"\n";
}
}
getch();
}
Comments
Post a Comment