Wap to display the following numeric series.

Using for loop:

#include<stdio.h>
#include<conio.h>
void main(){
int x,y;
for(x=1;x<=5;x++)
{
for(y=1;y<=x;y++)
{
printf("%d",y);
}
printf("\n");
}
getch();
}

Using while loop:

#include<stdio.h>
#include<conio.h>
void main()
{
int a=1;
while(a<=5)
{
int b=1;
while(b<=a)
{
printf("%d",b);
b++;
}
printf("\n");
a++;
}
getch();
}

Using do…while loop

#include<stdio.h>
#include<conio.h>
void main()
{
int a=1;
do
{
int b=1;
do
{
printf("%d",b);
b++;
}while(b<=a);
a++;
printf("\n");
}while(a<=5);
getch();
}

About the author

ProPathshala

View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *