Ciao, il codice che sto cercando di scrivere correttamente dovrebbe servire a calcolare un numero fattoriale, ma quando provo a compilarlo mi da errore alla riga della condizione di termine if. Qualcuno può aiutarmi a scrivere correttamente questo codice?Grazie.
il log di complazione è:codice:#include <stdio.h> int main() int fattoriale(int x) { if (x==0) return 1; int fatt = x * fattoriale(x-1); return fatt; };
codice:Compilatore: Default compiler Esecuzione di gcc.exe... gcc.exe "C:\Documents and Settings\Home\Desktop\fattoriale.c" -o "C:\Documents and Settings\Home\Desktop\fattoriale.exe" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" C:\Documents and Settings\Home\Desktop\fattoriale.c: In function `main': C:\Documents and Settings\Home\Desktop\fattoriale.c:7: error: syntax error before '{' token C:\Documents and Settings\Home\Desktop\fattoriale.c:9: error: parameter `fatt' is initialized C:\Documents and Settings\Home\Desktop\fattoriale.c:9: error: `x' undeclared (first use in this function) C:\Documents and Settings\Home\Desktop\fattoriale.c:9: error: (Each undeclared identifier is reported only once C:\Documents and Settings\Home\Desktop\fattoriale.c:9: error: for each function it appears in.) C:\Documents and Settings\Home\Desktop\fattoriale.c:9: confused by earlier errors, bailing out Esecuzione terminata

Rispondi quotando
