VitorH

Untitled

May 20th, 2012
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4.     int num,div,resto,soma=0;
  5.     printf("Digite um numero para saber se ele e perfeito: ");
  6.     scanf("%d",&num);
  7.     for (div=1;div<num;div++)
  8.     {
  9.         resto=num%div;
  10.         if (resto==0)
  11.         {
  12.             soma=soma+div;
  13.         }
  14.     }
  15.     if (soma==num)
  16.     {
  17.         printf("O numero e perfeito!!!");
  18.     }
  19.     else
  20.     {
  21.         printf("O numero nao e perfeito!!!");
  22.     }
  23.     return(0);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment