C program to create a inverted symbol triangle or pyramid pattern.
In this tutorial we will learn how to write a C program to create or print a inverted pyramid or triangle pattern by using symbols.
We will create a reverse triangle pattern by symbols as star symbol.
In this tutorial we will learn how to write a C program to create or print a inverted pyramid or triangle pattern by using symbols.
We will create a reverse triangle pattern by symbols as star symbol.
Example:
**********
*********
********
*******
******
*****
****
***
**
*
C program code
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,num,count=0;
clrscr();
printf("\n Enter the number of rows:\n ");
scanf("%d",&num);
printf("\n");
for(a=num;a>=1;a--)
{
for(c=1;c<=count;c++)
{
printf(" ");
}
for(b=1;b<=a;b++)
{
printf("*");
}
printf("\n");
count++;
}
getch();
}
OUTPUT:
In this output we can see that the range or size of pyramid is 30 and the total lines of symbols in this pyramid is 30.
we will enter the range(size) of this pyramid and press the enter button then the pyramid will be print on to the screen.This inverted pyramid is a triangle also.
Other c program code
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,num,count=0;
clrscr();
printf("\n Enter the number of rows:\n ");
scanf("%d",&num);
printf("\n");
for(a=num;a>=1;a--)
{
for(c=1;c<=count;c++)
{
printf(" ");
}
for(b=1;b<=a;b++)
{
printf(" *");
}
printf("\n");
count++;
}
getch();
}
OUTPUT:
In these outputs, we will see that these program codes create a symbol triangle or pyramid pattern.
In this output we can see that the range or size of pyramid is 25 and the total lines of symbols in this pyramid is 25.
we will enter the range(size) of this pyramid and press the enter button then the pyramid will be print on to the screen.This inverted pyramid is a triangle also.
Please share this post and blog link with your friends.For more programs use this blog.
If you have any problem, please comment in comment box, subscribe this blog for notifications of new post on your email and follow this blog.If you have any method of this program or want to give any suggestion send email on hc78326@gmail.com
No comments:
Post a Comment