Hi everyone, Iam having an error while executing this code:-
The error is:-
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/11/../../../../lib64/crt1.o: in function `_start': (.text+0x24): undefined reference to `main' collect2: error: ld returned 1 exit status
Here is the code of both the files:-
main.c:-
#include"headers.h" #include"declarations.h" int main(){ int a; a = factorial(); printf("factorial is %d\n",a); return 0; }
factorial.c:-
#include"headers.h" #include"declarations.h" int factorial(){ int n; printf("enter a number\n"); scanf("%d",&n); int fact = 1; for(int i=0;i<n;i++){ fact*=i; } printf("factorial is %d\n",fact); return fact; }