#include<iostream.h>
#include<conio.h>
void assend1(int);
void assend2(int);
void decend(int);
void triangle(int);
void main()
{
int i,j,n;
clrscr();
cout<<"enter the value of n";
cin>>n;
cout<<"\nthe series 1 is: \n";
assend1(n);
cout<<"\nthe series 2 is ";
assend2(n);
cout<<"\nthe series 3 is\n";
decend(n);
cout<<"\nthe series 4 is \n";
triangle(n);
getch();
}
void assend1(int n)
{
int i,j;
for(i=1;i<=n;i++)
{
for(j=i;j>=1;j--)
{
cout<<" "<<j;
}
cout<<"\n";
}
}
void assend2(int n)
{
int i,j;
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
cout<<" "<<j;
}
cout<<"\n";
}
}
void decend(int n)
{
int i=n,j;
while(i>=1)
{
for(j=i;j>=1;j--)
{
cout<<" "<<j;
}
cout<<"\n";
i--;
}
}
void triangle(int n)
{
int i,j,k,l;
//cout<<n;
for(i=1;i<=n;i++)
{
j=i;
//for(j=i;j<n;j++)
do
{
cout<<" ";
}
while(j++<n);
for(k=1;k<=i;k++)
{
cout<<k;
}
for(l=i-1;l>=1;l--)
{
cout<<l;
}
cout<<"\n";
}
}
#include<conio.h>
void assend1(int);
void assend2(int);
void decend(int);
void triangle(int);
void main()
{
int i,j,n;
clrscr();
cout<<"enter the value of n";
cin>>n;
cout<<"\nthe series 1 is: \n";
assend1(n);
cout<<"\nthe series 2 is ";
assend2(n);
cout<<"\nthe series 3 is\n";
decend(n);
cout<<"\nthe series 4 is \n";
triangle(n);
getch();
}
void assend1(int n)
{
int i,j;
for(i=1;i<=n;i++)
{
for(j=i;j>=1;j--)
{
cout<<" "<<j;
}
cout<<"\n";
}
}
void assend2(int n)
{
int i,j;
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
cout<<" "<<j;
}
cout<<"\n";
}
}
void decend(int n)
{
int i=n,j;
while(i>=1)
{
for(j=i;j>=1;j--)
{
cout<<" "<<j;
}
cout<<"\n";
i--;
}
}
void triangle(int n)
{
int i,j,k,l;
//cout<<n;
for(i=1;i<=n;i++)
{
j=i;
//for(j=i;j<n;j++)
do
{
cout<<" ";
}
while(j++<n);
for(k=1;k<=i;k++)
{
cout<<k;
}
for(l=i-1;l>=1;l--)
{
cout<<l;
}
cout<<"\n";
}
}
No comments:
Post a Comment