Advertisement
Guest User

Soma e fatorial

a guest
Mar 26th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4.  
  5.   int num, soma, fatorial;
  6.  
  7.   scanf("%d", &num);
  8.   soma = 0;
  9.   fatorial = 1;
  10.  
  11.   if (num > 0) {
  12.     while (num > 0) {
  13.       soma = soma + num;
  14.       fatorial = fatorial * num;
  15.       num = num - 1;
  16.     }
  17.  
  18.     printf("soma: %d\n", soma);
  19.     printf("fatorial: %d\n", fatorial);
  20.   }
  21.  
  22.   return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement