Sunday, June 26, 2011
C Programming - Program Membuat Segitiga Pascal
#include <stdio.h>
int bil, a, i, j, k;
int main()
{
int pascal(int);
printf("Masukkan sebuah nilai: ");
scanf("%d", &bil);
for (i=0; i<=bil; i++)
{
for (k=0; k<=((2*bil)-(2*i)); k++)
{
printf(" ");
}
for (j=0; j<=i; j++)
{
pascal(j);
}
printf("\n");
}
return 0;
}
int pascal(j)
{
if (j==0||i==j)
{
a=1;
}
else
{
a=a*(i+1-j)/j;
}
printf("%4i", a);
}
Labels:
C Language
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment