Wednesday, 23 April 2014

Write a program to print the following pattern: 1 b) 1 1 2 2 2 1 2 3 3 3 3 1 2 3 4 4 4 4 4 1 2 3 4 5 5 5 5 5 5

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,num_lines;
clrscr();
printf("\nEnter the number of lines to print: ");
scanf("%d", &num_lines);
for(i=1; i<=num_lines; i++)
{
for(j=1; j<=i; j++)
{
printf("%d ", j);
}
printf("\n");
}
getch();
}

No comments:

Post a Comment