moranguinho

ex11ER3

Apr 10th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. /*11) Ler um número inteiro e determinar se o mesmo é primo. Um número é primo
  2. quando é divisível de maneira exata somente por 1 e por ele mesmo.*/
  3. #include <stdio.h>
  4. int main(void)
  5. {
  6. int num, qtd=0, i;
  7.  
  8. printf("Informe um numero: ");
  9. scanf("%d", &num);
  10.  
  11. for(i=2;i<=num/2;i++)
  12. {
  13. if(num%i==0)
  14. {
  15. qtd++;
  16. break;
  17. }
  18. }
  19. if(qtd==0)
  20. {
  21. printf("%d primo", num);
  22. }
  23. else
  24. printf("%d Nao primo", num);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment