Description

Pascal Triangle Code :

#include<stdio.h>

long factorial(int n);

int main(){
    int row;
    printf("Enter the row of Pascal Triangle : ");
    scanf("%d", &row);
    for(int i=0; i<row; i++){
        for(int j=0; j<row-i-1; j++){
            printf(" ");
        }
        for(int j=0; j<=i; j++){
            printf("%ld ", factorial(i)/(factorial(j) * factorial(i-j)));
        }
        printf("\n");
    }
    return 0;
}
long factorial(int n){
    long fact = 1;
    for(int i=1; i<=n; i++){
        fact = fact * i;
    }
    return fact;
}

Output :

Comments

Login is mandatory to comment Please login

Recommended Posts

Leap Year | Leap year program in c

Year is divisible by completely 4,100,400 then called that year is leap year.

Perfect Number in C Programming

What is Perfect Number? Perfect Number is a positive integer number that is equal to the sum of the its possible factors.
For Example : 6 is a Perfect Number

Strong Number in C programming | What is Strong Number

Strong Number is a number whose sum of the factorial of digits of number is equal to given number.
For Example : 145 is a strong number.

Neon Number | c programming language

A neon number is a number if the sum of the square of that number is equal to the actual number, then it is a neon number. For Example : 9 is a neon number.

C programming restaurant menu code | @lapmos

In this tutorial we write a c program which print the menus of restaurant with product and price.

Primary Arithmetic program in c programming and cpp programming language

Write a c and c++ programming language , primary Arithmetic Program