Program to generate Pascal's triangle

Program:

#include<stdio.h>
#include<conio.h>
void main()
{
    int b, p, q, r, x;
    clrscr();
    b = 1;
    q = 0;
    printf("Enter the number of rows : ");
    scanf("%d", &p);
    printf("\nPascal's triangle is : \n\n");
    while (q < p)
    {
        for(r = 40 - 3 * q ; r > 0 ; --r)
        printf(" ");
        for(x = 0 ; x <= q ; ++x)
        {
            if((x == 0) || (q == 0))
            b = 1;
            else
            b = (b * (q - x   1)) / x;
            printf("%6d", b);
        }
        printf("\n\n");
          q;
    }
    getch();
}

Output:

Enter the number of rows : 5
Pascal's triangle is :
          1
       1    1
     1   2    1
   1   3    3    1
 1   4   6   4    1