Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h> se for Windows use essa linha
- int fatorial () {
- int fatorial;
- int resultado = 1;
- printf("Digite um numero: ");
- scanf("%d", &fatorial);
- int fatorialBackup = fatorial;
- for (fatorial = 0; fatorial >= 1; --fatorial) {
- resultado*=fatorial;
- }
- printf("Fatorial de %d: %d\n", fatorialBackup, resultado);
- }
- int main () {
- //programa simples em C
- //chamando uma função
- fatorial();
- system("pause"); se for Windows descomente essa linha
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment