TutorialStudyMite

Pascal’s triangle in C

NNamrata Jangid2 min read
Beginner friendly

Track completion, mastery, and revision.

Pascal Triangle/Pyramid Program in C

The code for printing Pascal’s triangle is:

With special characters:

#include <stdio.h>
int  main()
{
int  i, j, n, k = 0;
printf("Enter number of rows: ");
scanf("%d", & amp; n);
printf("\n");
for (i = 1; i & lt; = n; ++i, k = 0)
{

}
return  0;
}

The output for the above code is:

Enter number of rows:  7









With numbers:

#include <stdio.h>
int  main()
{
int  i, j, n, k = 0, count = 0, count1 = 0;
printf("Enter number of rows: ");
scanf("%d", & amp; n);
for (i = 1; i & lt; = n; ++i)
{

}
return  0;
}

The output for the above code is:

Enter number of rows:  5
1
2 3 2
3 4 5 4 3
4 5 6 7 6 5 4
5 6 7 8 9 8 7 6 5

Finished reading?

Was this helpful?

Your feedback shapes better tutorials for everyone.