NEP -DATA STRUCTURE

PART-A

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8

PART-B

PROGRAM B1 PROGRAM B2 PROGRAM B3 PROGRAM B4 PROGRAM B5 PROGRAM B6 PROGRAM B7 PROGRAM B8 . . .

2. Write a C Program to display Pascal Triangle using binomial function

 
  
 
 
/*2. Write a C Program to display Pascal Triangle using binomial function*/


#include < stdio.h >   
long factorial(int);  
int main()  
{  
    int i, n, c;  
    printf("Enter the number of rows you wish to see in pascal triangle\n");  
    scanf("%d", & n);  
    for (i = 0; i < n; i++) {  
        for (c = 0; c <= (n - i - 2); c++) printf(" ");  
        for (c = 0; c <= i; c++) printf("%ld ", factorial(i) / (factorial(c) * factorial(i - c)));  
        printf("\n");  
    }  
    return 0;  
}  
long factorial(int n) {  
    int c;  
    long result = 1;  
    for (c = 1; c <= n; c++) result = result * c;  
    return result;  
}