C Program to Print V Numbers Pattern

Write a C program to print V numbers pattern using for loop.

#include <stdio.h>

int main()
{
	int rows;

	printf("Enter V Shape Number Pattern Rows = ");
	scanf("%d", &rows);

	printf("Printing the V Shape Number Pattern\n");

	for (int i = 1; i <= rows; i++)
	{
		for (int j = 1; j <= i; j++)
		{
			printf("%d", j);
		}
		for (int k = 1; k <= 2 * (rows - i); k++)
		{
			printf(" ");
		}
		for (int l = i; l >= 1; l--)
		{
			printf("%d", l);
		}
		printf("\n");
	}
}
C Program to Print V Numbers Pattern

This C program prints the alphabetical V pattern of numbers using a while loop.

#include <stdio.h>

int main()
{
	int rows, i, j, k, l;

	printf("Enter V Shape Number Pattern Rows = ");
	scanf("%d", &rows);

	printf("Printing the V Shape Number Pattern\n");

	i = 1;

	while (i <= rows)
	{
		j = 1;
		while (j <= i)
		{
			printf("%d", j);
			j++;
		}
		k = 1;
		while (k <= 2 * (rows - i))
		{
			printf(" ");
			k++;
		}
		l = i;
		while (l >= 1)
		{
			printf("%d", l);
			l--;
		}
		printf("\n");
		i++;
	}
}
Enter V Shape Number Pattern Rows = 8
Printing the V Shape Number Pattern
1              1
12            21
123          321
1234        4321
12345      54321
123456    654321
1234567  7654321
1234567887654321

This C example uses the do while loop to display the capital V pattern of numbers.

#include <stdio.h>

int main()
{
	int rows, i, j, k, l;

	printf("Enter V Shape Number Pattern Rows = ");
	scanf("%d", &rows);

	printf("Printing the V Shape Number Pattern\n");

	i = 1;
	do
	{
		j = 1;
		do
		{
			printf("%d", j);

		} while (++j <= i);

		k = 1;
		while (k <= 2 * (rows - i))
		{
			printf(" ");
			k++;
		}

		l = i;
		do
		{
			printf("%d", l);

		} while (--l >= 1);

		printf("\n");

	} while (++i <= rows);
}
Enter V Shape Number Pattern Rows = 9
Printing the V Shape Number Pattern
1                1
12              21
123            321
1234          4321
12345        54321
123456      654321
1234567    7654321
12345678  87654321
123456789987654321