Write a C Program to print below pattern ( Pyramid pattern ) :
*
* *
* * *
* * * *
* * * * *
* * * *
* * *
* *
*
Explanation :
This is one the series of pattern programs in C. This program accept one integer from the user and prints above triangle pattern( It prints pattern depending upon the number, above pattern is for n=4). Here I am using only two for loops to create above pattern. First for loop is responsible for the number of rows. so it always starts with -n. The inner loop is for columns. I am using small logic(using variable ‘k’) to accomplish this pattern with only two loops.
Program :
#include<stdio.h>
int main()
{
int i,j,k,n;
printf(“Enter the Value for n : “);
scanf(“%d”,&n);
for(i=-n;i<=n;i++) // Note that ‘i’ is starting from -n (negative n)
Hi Guys, I am Venkatesh Macha. I am a programmer and an Open Source enthusiast, Presently working as a Software Engineer. Apart from that, I love to explore new technologies and things.
Good Logic