Pascal triangle in C - Jagrav Education
BANNER 728X90

Tuesday, March 5, 2019

Pascal triangle in C

Question: WAP in "C" to find out the following output:



#include <stdio.h>

void main()
{
    int no_row,c=1,blk,i,j;
    printf("Input number of rows: ");
    scanf("%d",&no_row);
    for(i=0;i<no_row;i++)
    {
        for(blk=1;blk<=no_row-i;blk++)
        printf("  ");
        for(j=0;j<=i;j++)
        {
            if (j==0||i==0)
                c=1;
            else
               c=c*(i-j+1)/j;
            printf("% 4d",c);
        }
        printf("\n");
    }

}

No comments:

Post a Comment

Divi read more Text replace with custom text in divi builder via JS Query simple code in wordpress

  use simple JS Query for replace text  <script type="text/javascript"> (function($) { $(document).ready(function() { var ne...