Write a program in the c programming language to print an equilateral triangle of the asterisks or by using any other character. Make this program by using for loop statements. Below is the triangle we have to print as a output of the program-
Below is the code of the C program to print the above output –
/* C program to print Equilateral Triangle*/ #include<stdio.h> main() { int i,j,k,n; printf("Enter number of rows of the triangle \n"); scanf("%d",&n); for(i=1;i<=n;i++) { for(j=1;j<=n-i;j++) { printf(" "); } for(k=1;k<=(2*i)-1;k++) { printf("*"); } printf("\n"); } getch(); }
Ouput – Output will be exact as shown in the image above
This code is not for an equilateral triangle.
This is for an isosceles triangle.
No.. Its for Equilateral Triangle only.
Your posting really stghiratened me out. Thanks!
zegt:Op de Nederlandse site is een wachtlijst voor de gele die ik zo graag wil….Net een Louis Vuitton tas, maar dan leuker!Vind het wel chique, geloof ik
12th line me “n-i” nhi only “n” hoga
nito..
it says error: function should return a value
Exrltmeey helpful article, please write more.
It seems to me that this web site doesnt load up on a Motorola Droid. Are other people having the same problem? I like this website and dont want to have to skip it any time Im gone from my computer.
I am with you on both points. Knowing who the historical characters are absolutely adds to the sense of nostalgia and mystique about Paris that Gil feels. A scene that stands out is when Gil was planting the plot of The Exterminating Angel in Luis Bunuel’s head. I got a good laugh out of that exchange but I was the only person in the theater who seemed to get the reference (or I was just the only person obnoxiously laughing out loud). I also plan on giving Midnight in Paris another look later in the year. Thanks for commenting!
wrote and article last week on leaves in a stream and I was reminded that people come together and drift apart for a reason. Jen, I’m learning to embrace the ride AND I’m so grateful for you and everyone else who share this moment with me![]
Correct. Its silly to assume that every single man can beat every single girl. Its naive.Just as there are very weak men, there are very strong girls. The sexes are not always what they are meant to be. lol. I do martial arts and can defend myself. Of course i can beat most girls but im sure there are many women who can beat me up. We are talking about the whole world, where theres millions of women.
bakvas codding
sorry,….
WITH THE HELP OF TWO LOOPS..YOU BETTER DO THIS WAY
#include
void main()
{
int i,j;
for(i=1;i<=4;i++)
{
for(j=1;j=(5-i))
{
printf(“*”);
}
else
{
printf(” “);
}
}
printf(“\n”);
}
}
if j doesn’t get incremented won’t it be an endless loop
and how can you use else without if
/* printing one row in every iteration */
for(i = 1; i <= rows; i++) {
/* Printing spaces */
for(space = 1; space <= rows-i; space++) {
printf(" ");
}
/* Printing stars */
while(star != (2*i – 1)) {
printf("*");
star++;;
}
star=0;
/* move to next row */
printf("\n");
}
Source : pyramid triangle star pattern
0
1
2 4
3 5 7
6 8 10 12
9 11 13 15 17
I have noticed you don’t monetize your blog, don’t waste your traffic, you can earn extra cash every month because you’ve got
high quality content. If you want to know how to make extra money, search for: Boorfe’s tips best adsense alternative
a flowchart that print dimond pattern