Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. main () {
  4.  
  5. int i, num , resto = 0 ;
  6.  
  7. printf ("Ola, meu nome eh William Vargas e vou calcular numeros primos...\n");
  8.  
  9. do
  10. {
  11. printf ("\nEntre com um numero positivo\t:");
  12. scanf ("%d", &num);
  13. }
  14. while (num<=0);
  15.  
  16.  
  17.  
  18. for (i = 1; i <= num && resto <= 3 ; i++)
  19. {
  20. if(num % i==0)
  21. resto++ ;
  22. }
  23.  
  24. if (resto==2)
  25. printf("\n %d Eh um numero primo", num );
  26. else
  27. printf("\n%d Nao eh um numero primo", num );
  28.  
  29. int p;
  30. {
  31.  
  32. printf("\nDeseja continuar (1-Sim/2-Nao) ? ");
  33. scanf("%d, &p ");
  34. if(p==1)
  35.  
  36. printf("\nObrigado, ate a proxima! Para ver o meu codigo entre no link (Seu link do Github)");
  37. else
  38. printf ("\nEntre com um numero positivo\t:");
  39. scanf ("%d", &num);}
  40. return 0;
  41. system("pause");
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement