Write a program to display Pascals Triangle to the given num
     Write a program to display Pascal\'s Triangle to the given number of rows defined by the user The way to compute any given position\'s value is to add up the numbers to the position\'s right and left in the preceding row. The sides of the triangle are always 1 because you only add the number to the upper left or the upper right(there being no second number on the outer side).The program should prompt the user to input the number of rows to display and then print Pascal\'s Triangle as shown. The program should ensure that the input is valid before computing a value for the position.   
  
  Solution
#include <stdio.h>
int main(void)
 {
 int i,j,rows,k,space;
 long c;
   
 printf(\"\ Enter number of rows to display: \"); //validate the value of rows
 scanf(\"%d\",&rows);
 if(rows<0 || rows==0)
 printf(\"\  Error:Enter the positive value greater than 0 for rows \");
 scanf(\"%d\",&rows);
   
 printf(\"\ \");
   
 space=rows;
 for(i=0;i<rows;i++)
 {
 c=1; //first value in row is always 1
 for(k=space;k>=0;k--) //space on left of 1 ,decreases with increase of rows
 {
 printf(\" \");
 }
 space--;
 for(j=0;j<=i;j++)
 {
 printf(\"%6ld\",c); // first value in row displays 1,6ld gives space before number
 c=(c*(i-j)/(j+1)); // numbers in 1 row
 }
 printf(\"\ \");
 }
 return 0;
 }
Output:
Success time: 0 memory: 2172 signal:0

