Disqus Shortname

Tuesday, August 18, 2015

Program: Pascal Triangle





#include <stdio.h>

long fact(int);

int main() {

int baris, i, j;

printf("Masukan banyak baris: ");
scanf("%d", &baris);

for (i = 0; i < line; i++) {

for (j = 0; j < line - i - 1; j++){

printf(" ");

}


for (j = 0; j
printf("%ld ", fact(i) / (fact(j) * fact(i - j)));

}

printf("\n");

}
return 0;

}

long fact(int num) {

long f = 1;
int i = 1;

while (i
f = f * i;

i++;
}

return f;

}

1 comment: