Prime Number

Write a program to take a number as input and show weather the number is prime or not.
#include


#include

void main(void)

{

clrscr();

int n,num,rem;

printf("Enter number = ");

scanf("%d",&n);

for(num=(n-1);num>1;num--)

{

rem=n%num;

if (rem==0)

{

printf("%d=Not Prime",num);

break;

}

}

if(rem!=0)

printf("%d=Prime",num);

getch();

}

Comments

Popular posts from this blog

Tip of the Day # 13

Governor Generals of Pakistan