how print triangles in c

Solutions on MaxInterview for how print triangles in c by the best coders in the world

showing results for - "how print triangles in c"
Nico
06 May 2018
1#include <stdio.h>
2int main() {
3   int rows, i, j, space;
4   printf("Enter the number of rows: ");
5   scanf("%d", &rows);
6   for (i = rows; i >= 1; --i) {
7      for (space = 0; space < rows - i; ++space)
8         printf("  ");
9      for (j = i; j <= 2 * i - 1; ++j)
10         printf("* ");
11      for (j = 0; j < i - 1; ++j)
12         printf("* ");
13      printf("\n");
14   }
15   return 0;
16}
17
Giuseppe
01 Jan 2021
1#include <stdio.h>
2int main() {
3   int rows, coef = 1, space, i, j;
4   printf("Enter the number of rows: ");
5   scanf("%d", &rows);
6   for (i = 0; i < rows; i++) {
7      for (space = 1; space <= rows - i; space++)
8         printf("  ");
9      for (j = 0; j <= i; j++) {
10         if (j == 0 || i == 0)
11            coef = 1;
12         else
13            coef = coef * (i - j + 1) / j;
14         printf("%4d", coef);
15      }
16      printf("\n");
17   }
18   return 0;
19}
20
Leah
25 Feb 2017
1           1
2         1   1
3       1   2   1
4     1   3   3    1
5   1  4    6   4   1
6 1  5   10   10  5   1
7
Lisa
08 Nov 2019
1* * * * * * * * *
2  * * * * * * *
3    * * * * *
4      * * *
5        *
6
queries leading to this page
java code to print pascal 27s trianglewrite a function which prints the pascal 27s triangle as shown below 3apascal triangle using cfull inverted pyramid using 2a in ccode for pascal triangleprint pascal number triangleprocedural loop pyramudwrite a program to print pascal 27s triangletriangle programs in cprint pascal 27s trianglepattern printing in cprint pascals triangle schemeprint pascal triangle in cpppattern program in cc program to print pascal 27s trianglec program to print triangletriangel logic in cc programs triangles printfastest way to print pascals triangle c 2b 2bhow to print pascal triangle in c 2b 2bwrite a program to print pascal triangle pattern design in cpyramid structure by using chow to print a triangle in cprint pascal triangle gfg practiceprint triangles in cpascal triangle c programprint pascal triangle in schemeprogram to print pascal trianglepascal triangle pattern in cpascal triangle codec code for floyed pyramidwrite a c program to print pascal triangle for a given numberprint triangle on side in cpascal 27s triangle iiprint pascal triangle in cjava program to display pascal trianglepascal triangle print how to print right triangle using cprints a triangle using 27 2a 27 in cwrite ac program to display pascal 27s triangleprintf triangle a in cc program for pyramid of starspatterns in cgiven an integer n 2c print the corresponding inverted full pyramid pattern for n for example if n 3d 5 then pattern will be like 3a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a program to print the pascal triangle in cpptriangle in cprint number triangle in cprint right sided triangle in chow to make pascal 27s triangle using cpascal triangle program in cprogram to print triangle of numbers in cpascal triangle in chow to print triangle using cwrite a program to print pascal triangle inchow to code pascal triangle in cpascal triangle c how to print a pascal s triangle in chow print triangles in cprint pascal triangle in c 2b 2btriange cprinting triangles in cprinting patterns in cprinting right triangle in cc programs pyramidjava program to print pascal trianglec print pascals trianglewrite a program to print pascal triangle in cc program to print triangle usingprint pascal 27s triangle schemeprint pascal trianglewrite a c program to print pascal triangleprogram to find the total of pascal triangle in cprinting a triangle in cprint rom pyramidpascal 27s triangle in cc pascals trianglehow to print a pyramid in chow to print triangle in cpascal triangle c codehow to print pascal triangle in cwrite a program to print pascal 27s triangle for a given number of rows pascal trianglehow to make pascal triangle in c using while loophow to program pascal 27s triangleprint a pascal 27s trianglehow to make pascal triangle in c using whiulepyramid printing in cpascal 27s triangleprinting patternhow to print ascals triangelein cprint triangle in cprintf triangle in chow print triangles in c