Re: PASCAL'S TRIANGLE



GUPTAJI wrote:
hi all,

can u give me the code to create a Pascal's Triangle........... and
yes, it should work

If you can make this print one more row correctly, I will be impressed.


#include <stdio.h>

unsigned long factorial(unsigned long a){
return a == 0UL ? 1UL : a * factorial(a-1UL);
}

int main(int argc, char **argv){

unsigned long row, num, val, fact;

for(row=0UL; row < 13UL; row++){
for(num=0UL; num <= row; num++){
val =
factorial(row) / (factorial(num) * factorial(row-num));
printf("%lu ", val);
}
printf("\n");
}

return 0;
}
.



Relevant Pages

  • Re: [RFC] New kernel-message logging API
    ... return buf; ... static char* put_dec(char *buf, unsigned long long num) ... static int skip_atoi ...
    (Linux-Kernel)
  • Can I save ADODB.Command into a file?
    ... char buf; ... ULONG uread = 0; ... num = file.gcount; ... int main ...
    (microsoft.public.vc.atl)
  • resource_size_t printk whinging
    ... -asmlinkage int vprintk(const char *fmt, ... num = va_arg ...
    (Linux-Kernel)
  • hello-exploit.c
    ... int main(int argc, char *argv) { ... /*The greater the NUM of strlen- NUM, ... void help; ...
    (Bugtraq)
  • Re: Newbie question
    ... license, provide either the license text or at least ... int main ... If you have a good reason to use char, do so, of course. ... Since you have #define NUM, ...
    (comp.lang.c)