Featured
- Get link
- X
- Other Apps
C++ program to print pattern of numbers with each line reversing the previous line
//C++ program to print pattern of numbers with each line reversing the previous line
#include<iostream.h>
#include<conio.h>
void main()
{
int i,k,t,a=1,s=0;
clrscr();
for(i=6;i>=1; i--)
{
if(i%2==0)
{
for(k=1;k<=i;k++)
{
cout<<a<<" ";
++a;
}
cout<<"\n";
t=a;
}
if(i%2!=0)
{
for(s=t+i-1;s>=t;s--,a++)
{
cout<<s<<" ";
}
cout<<"\n";
}
}
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{
int i,k,t,a=1,s=0;
clrscr();
for(i=6;i>=1; i--)
{
if(i%2==0)
{
for(k=1;k<=i;k++)
{
cout<<a<<" ";
++a;
}
cout<<"\n";
t=a;
}
if(i%2!=0)
{
for(s=t+i-1;s>=t;s--,a++)
{
cout<<s<<" ";
}
cout<<"\n";
}
}
getch();
}
The output will be as following:
- Get link
- X
- Other Apps
Labels:
C program to print numbers pattern
C++ program to print pattern of numbers with each line reversing the previous line
Popular Posts
C++ program to display numbers which get reversed after multiplying by 4
- Get link
- X
- Other Apps
Comments
Post a Comment