0

[IMG]http://letscoding.files.wordpress.com/2010/12/4.jpg[/IMG]Something goes wrong but I can find it!! plese help!! run program and enter from 12 or larger

//Tolga Kayhan © 2010
//Let'sCoding
#include <stdio.h>
#include <stdlib.h>

//Pascal triangle in this example contains

int factorial(int);
int C(int,int);
void space(int);
void writer(int,int);


int main()
{
   int last,sender;
   do{
   printf("Enter a number from 0 or larger");
   scanf ("%d",&last);
   }while(last<0);

   for(sender=0;last>=sender;sender++)
   writer(sender,last);

   getch();
   return 0;
}

//****space printer****
void  space(int space)
{
   int counter;
   for(counter=0;space>=counter;counter++)
   {
      printf("  ");
   }
}

//*******factorial*****
int factorial(int incoming)
{
   int counter,result=1;
   for(counter=1;incoming>=counter;counter++)
   {
      result*=counter;
   }
   return result;
}

//***combination calculate***
int combinasyon(int n,int r)
{
   int result;
   result=factorial(n)/(factorial(r)*factorial(n-r));
   return result;
}

//*********printer***********
void writer(int incoming,int last)
{
   int counter;
   space(last-incoming);
   for(counter=incoming;counter>=0;counter--)
   printf("%4d",combinasyon(incoming,counter));
   printf("\n");
}
1
Contributor
1
Reply
3
Views
6 Years
Discussion Span
Last Post by kayhantolga
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.