ramontricolor12

LISTA 03 - Exercício 09

Jun 15th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. /* CABEÇALHO
  2.    Arquivo: LISTA 03 - Exercicio 9(usando while).c
  3.    Objetivo: Fatorial de um número com o comando while.
  4.    Autor(a): Ramon Borges
  5.  */
  6.  
  7. #include <stdio.h>
  8.  
  9. int main()
  10. {
  11.     int numero, fatorial;
  12.  
  13.     printf("\nInforme um numero: ");
  14.     scanf("%d", &numero);
  15.  
  16.     if(numero < 0)
  17.         printf("\nValor indeterminado.");
  18.  
  19.     else
  20.     {
  21.         fatorial = 1;
  22.         while(numero > 1)
  23.         {
  24.             fatorial *= numero;
  25.             numero--;
  26.         }
  27.     }
  28.     printf("Fatorial = %d", fatorial);
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment