img
Question:
Published on: 21 November, 2024

Write a C program to print the following pattern output.

1

1    2

1    2    3

1    2    3    4

1    2    3    4    5
Answer:
#include<stdio.h>
#include<conio.h>
main()
{
	int i,j,n;
	printf("\n enter how many lines");
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=i;j++)
		{
			printf("\t%d",j);
   		}
   		printf("\n");
	}
	getch();
}

Output:

Random questions