0
Why this code has erro
#include <stdio.h> int factorial (int n){ if (n == 1 || n == 0) { return 1; } eles { return n*factorial(n-1); } } int main() { int a; printf ("Pavel"); scanf("%d",a); printf ("Anik %d is %d\n",a,factorial (a)); return 0; }
3 Antworten
+ 2
#include <stdio.h>
int factorial (int n){
if (n == 1 || n == 0)
{
return 1;
}
else{//here it said eles
return n*factorial(n-1);
}
}
int main() {
int a;
printf ("Pavel");
scanf("%d",&a); //& ampersand was missing
printf ("Anik %d is %d\n",a,factorial (a));
//printf("%p",&a); /*display memory address of a*/
return 0;
}
/*when using scanf you need the memory address of the variable, not the variable itself, that is obtained by prepending "&"*/
+ 1
Bong Rush Gaming YT It has a misspelling of the keyword, else.
0
Ok thanks 😁