Advertisement
ThaisAlmeida

Lista funções questão 5

Jun 17th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. int FAT(int n)
  2. {
  3.     int resultado;
  4.     resultado = 1;
  5.     while(n>0)
  6.     {
  7.     resultado = resultado*n;
  8.     n--;
  9. }
  10. return resultado;
  11. }
  12.  
  13. int main()
  14. {
  15.     int N, fatorial, fatmais4;
  16.     do
  17.     {
  18.         printf("Digite um numero: ");
  19.         scanf("%d", &N);
  20.         if(N<0)
  21.         {
  22.             printf("numero invalido!");
  23.         }
  24.         }
  25.     }while(N<0);
  26.            
  27.             fatorial = FAT(N);
  28.             fatmais4 = fatorial+4;
  29.             printf("O fatorial eh: %d e o fatorial acrescido de 4 eh: %d", fatorial, fatmais4);
  30.            
  31.             return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement