#include <stdio.h>
#include <conio.h>
int main()
{
int num, i;
int flag;
flag = 0;
printf("Plz., enter any number to check, it is prime number or not... \n");
printf("Pz., enter any number: ");
scanf("%d", &num);
for (i = 2; i <= (num - 1); i++)
{
if (num % i == 0)
{
printf("The given %d is non-prime number.", num);
flag = 0;
break;
}
flag = 1;
}
if (flag == 1)
{
printf("You have enter a prime number.");
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter