i need help programming pascal's triangle in C. i looked at the old threads, and none of them really helped. its a simple program, so no getch() or anything special. i started to create an array and give each element values. when i tried to run it, my output it funky looking. heres my code:
#include "stdio.h"
void main()
{
int x, i, j;
int C[10][10];
printf("Enter the number of levels: \n");
scanf("%d", &x);
for (i=0; i<x; i++){
for (j=0; j<=i; j++){
if (j==0 || j ==1)
C[i][j] = 1;
else
C[i][j] = C[i-1][j-1] + C[i-1][j];
}
}
for (i=0; i<x; i++){
printf("\n");
for (j=0; j<x; j++){
printf("%d ", C[i][j]);
}
}
return;
}
also, is their a way to set the array as C[][]; or do i have to define its dimensions?