#include<iostream>
using namespace std;
void pat1(int n)
{
int i,j;
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
cout<<"*";
}
cout<<"\n";
}
}
void pat2(int n)
{
int i,j;
for(i=1;i<=n;i++)
{
for(j=1;j<=n-i+1;j++)
{
cout<<"*";
}
cout<<"\n";
}
}
void pat3(int n)
{
int i,j;
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
cout<<"*";
}
cout<<"\n";
}
for(i=1;i<n;i++)
{
for(j=1;j<n-i+1;j++)
{
cout<<"*";
}
cout<<"\n";
}
}
main()
{
//clrscr();
int n,ch;
cout<<"Enter the number of lines";
cin>>n;
cout<<"\n1. Pattern 1";
cout<<"\n2. Pattern 2";
cout<<"\n3. Pattern 3";
cout<<"\n4. Exit";
cout<<"\n Enter your choice=";
cin>>ch;
switch(ch)
{
case 1:
pat1(n);
break;
case 2:
pat2(n);
break;
case 3:
pat3(n);
break;
case 4:
break;
default:
cout<<"\nWrong choice";
}
//getch();
}
using namespace std;
void pat1(int n)
{
int i,j;
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
cout<<"*";
}
cout<<"\n";
}
}
void pat2(int n)
{
int i,j;
for(i=1;i<=n;i++)
{
for(j=1;j<=n-i+1;j++)
{
cout<<"*";
}
cout<<"\n";
}
}
void pat3(int n)
{
int i,j;
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
cout<<"*";
}
cout<<"\n";
}
for(i=1;i<n;i++)
{
for(j=1;j<n-i+1;j++)
{
cout<<"*";
}
cout<<"\n";
}
}
main()
{
//clrscr();
int n,ch;
cout<<"Enter the number of lines";
cin>>n;
cout<<"\n1. Pattern 1";
cout<<"\n2. Pattern 2";
cout<<"\n3. Pattern 3";
cout<<"\n4. Exit";
cout<<"\n Enter your choice=";
cin>>ch;
switch(ch)
{
case 1:
pat1(n);
break;
case 2:
pat2(n);
break;
case 3:
pat3(n);
break;
case 4:
break;
default:
cout<<"\nWrong choice";
}
//getch();
}
No comments:
Post a Comment