Advertisement
xxGIANxx

fatorial - while

Dec 11th, 2012
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. main()
  5. {
  6.       int NUM, ACM = 1;
  7.      
  8.       printf("Digite o numero que vai ser calculado o fatorial: \n");
  9.       scanf("%d", &NUM);
  10.      
  11.       while(NUM>0) // laço de repetição; enquando a variavel for maior que 0 ele vai executar o laço
  12.       {
  13.                   ACM = ACM*NUM;
  14.                   NUM--; // condição para ir subtraindo o numero
  15.       }
  16.      
  17.       printf("\n\n\nO resultado do fatorial sera: %d \n\n\n", ACM);
  18.       system("pause");
  19.      
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement