Advertisement
RuiViana

AA_C_Numero_Primo

Mar 7th, 2021 (edited)
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2. int main(int argc, char **argv)
  3. {
  4.     int num, verificaPrimo;
  5.     int flag;
  6.     printf("Informe o numero a ser analisado entre 0 e 1000: ");
  7.     scanf("%i", &num);
  8.     for(int i=2; i<num +1;i++)
  9.     {
  10.         verificaPrimo=num%i;
  11.        // printf("verificaPrimo %d \n", verificaPrimo);
  12.         if (num > i)
  13.         {
  14.             if (verificaPrimo==0)
  15.             {
  16.                 printf("O valor %d nao e primo\n", num);
  17.                 break;
  18.             }
  19.         }
  20.         else
  21.         flag = 1;
  22.     }
  23.     if (flag == 1)
  24.         printf("O valor %d e primo\n", num);
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement