therajat08

prime num check

Oct 9th, 2019
29
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. #include<conio.h>
  3. int main()
  4. {
  5.     int num, i, count=0;
  6.     printf("Enter a number: ");
  7.     scanf("%d", &num);
  8.     for(i=2; i<num; i++)
  9.     {
  10.         if(num%i == 0)
  11.         {
  12.             count++;
  13.             break;
  14.         }
  15.     }
  16.     if(count==0)
  17.         printf("\nIt's a prime number");
  18.     else
  19.         printf("\nIt's not a prime number");
  20.     getch();
  21.     return 0;
  22. }
RAW Paste Data