You're online now.

Hurray! you are online now.

Pascal Triangle C programming

// print pascal triangle
    #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;
    }
🖤 0
Buy me coffee ☕

Comments

Oops!

No comments here...