Pattern Pyramid with Numbers in C

As we have learned simple patterns and complex patterns using for loop in our previous articles, now we are going to demonstrate complex numerical pattern pyramids. I advise to refer earlier posts in C Programming if you have not refereed yet for better understanding.

void main()
	int i,j,k,sp=-1;

		//First Half of Pyramid
		printf("%d ",j);

		//Loop for Space No Space in First Row So sp is initialized with -1
		//From second line 2 increment in space

		printf("  ");//two spaces
		sp+=2; //Two Increment in Space

		//Loop for Another Triangle
	//For first row we start with 5-1= 4 and for another rows 4,3,2
		j= i-1;

		for(;j>=1;j--)//Initialization part is not placed
		printf("%d ",j);
1 2 3 4 5 4 3 2 1
1 2 3 4   4 3 2 1
1 2 3       3 2 1
1 2           2 1
1               1
Complex Pyramid Program with Numbers In C

As we have used Nesting of Loops . We can use any loop for the same programs. Even Without Loop using goto (Jump Statement) we can develop the same program. You can try the same and place the program in Comment Section.

Don’t forget to subscribe to get Latest Updated Programs.

Leave a Reply

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

× How can I help you?