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; }

27th Dec 2021, 4:47 PM
Bong Rush Gaming YT
3 Respuestas
+ 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 "&"*/
27th Dec 2021, 4:55 PM
CGM
CGM - avatar
+ 1
Bong Rush Gaming YT It has a misspelling of the keyword, else.
27th Dec 2021, 4:57 PM
Brian
Brian - avatar
0
Ok thanks 😁
28th Dec 2021, 2:56 PM
Bong Rush Gaming YT