renix1

Fatorial em C //Simples

Jan 23rd, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h> se for Windows use essa linha
  3. int fatorial () {
  4.     int fatorial;
  5.     int resultado = 1;
  6.     printf("Digite um numero: ");
  7.     scanf("%d", &fatorial);
  8.     int fatorialBackup = fatorial;
  9.     for (fatorial = 0; fatorial >= 1; --fatorial) {
  10.         resultado*=fatorial;
  11.     }
  12.     printf("Fatorial de %d: %d\n", fatorialBackup, resultado);
  13. }
  14. int main () {
  15.     //programa simples em C
  16.     //chamando uma função
  17.     fatorial();
  18.     system("pause"); se for Windows descomente essa linha
  19.     return(0);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment