//NUMBER WHICH IS NOT MULTILE OF ANY NO. OTHER THAN 1 IS A PRIME NO..FOR EG 2 3 5 7 11 13 17 19 23 ETC...NUMBER WHICH IS MULTIPLE OF OTHER SMALL NO.S THAN NUMBER IS NOT A PRIME NUMBER..//
#include<stdio.h>
int main()
{
int i=0,num,rem=1;
do
{
printf("ENTER THE NUM:\n");//get the from command line to find no. is prime or not..//
scanf("%d",&num);
for(i=2;rem!=0;i++)
rem=num%i;//divide number by i ....if number is divisible by i untill i==number....//means if in any case number is divisible by i untill i less than number..means rem become 0 for i<num..//then no. is not a prime number..//
//if number is divisible by i when i==number....when remainder rem become 0..//then that means number is divisible by itself...//means number is a prime number..//
if((i-1)==num)//as in the for loop when condition is wrong at the last time,,,,i increments 1 more after rem ==0...//when condition got false so ...//number is compaired to (i-1);;;;
printf("no. is a prime no.\n");//if num==i ..then is a prime number..//
else
printf("no. is not a prime no\n");//if number is divisible by i for i<num..//means number is divisible by small value thsn number....then number is not a prime number..//
}while(num !=0);//it continuous checking if number is prime or not..//