Please hepl me about how to declare a function in dev-c++.I did it as following but it didn't work . Code: #include<stdio.h> #include<stdlib.h> fac(int p); void main() { int a,d,e; scanf("%d",&a); scanf("%d",&d); e=fac(a)/(fac(d)*fac(a-d)); printf("%d",e); return 0; system("pause"); } fac(int p) { int p,b,c; for(c=1;c<=p;c++){b=b*c;} return b; } } I used dev-c++ 4.9.9.2 .
Code: #include<stdio.h> #include<stdlib.h> int fac(int p); int main(){ int a,d,e; scanf("%d",&a); scanf("%d",&d); e=fac(a)/(fac(d)*fac(a-d)); printf("%d",e); return 0; system("pause"); } int fac(int p){ int p,b,c; b = 1; for(c=1;c<=p;c++){ b=b*c; } return b; } I think you make so many error in your code. If your function will return integer, you must give the int to the function data type. It shows the data type it will return. You cannot use void main in dev-cpp. To make factorial function, you can try the recursive method. Find out.