w3ajay

tally tutorial point, ms word 2013, ms excel 2013, ms powerpoint 2010,ccc question with answer in hindi 2021, Tally Prime in hindi , tally prime,Python,in python,programming in python,python

Wednesday, January 1, 2020

C Program to Display Pascal triangle



#include <stdio.h>
#include<conio.h>
void main()
{
    int rows, cal = 1, space, i, j;
    printf("Enter number of rows: ");//enter number of rows for generating the pascal triangle
    scanf("%d",&rows);
    for(i=0; i<rows; i++)            // outer loop for displaying rows
    {
        for(space=1; space <= rows-i; space++)  // space for every row starting
            printf("  ");
        for(j=0; j <= i; j++)     // inner loop for displaying the pascal triangle of numbers
        {
            if (j==0 || i==0)     // either outer loop value or inner-loop value is "0 " it prints 1
                cal = 1;
            else
                cal = cal*(i-j+1)/j;  //calculate the coefficient
            printf("%4d", cal);
        }
        printf("\n");
    }
    getch();
}


दोस्तों अगर आपको मेरी यह पोस्ट अच्छी लगी हो तो 
      प्लीज  like , share ,कमेंटसब्सक्राइब   जरुर करे जिससे हम आपके 
            लिए ऐसे ही अच्छे से अच्छे पोस्ट लाते  रहे 
अगर आपके पास कोई प्रश्न हो तो कमेंट बॉक्स में उस प्रश्न जरुर लिखे 

              धन्यवाद !

No comments:

Post a Comment

for more information please share like comment and subscribe