WELCOME

Welcome to KoDes4U

Pages

Monday, March 14, 2011

prime number(c program)

/*Write a program to find whether a user entered number is prime or not. Coded for KoDes4U.blogspot.com*/

#include
#include

void main()
{
int num,i=2;
clrscr();
printf("\nEnter a number:");
scanf("%d",&num);
while(i<=num)
{
if(num%i==0)
{
printf("\nNot a prime number.");
break;
}
else
{
if(i==num/2)
printf("Prime number");
break;
}
i++;

}
getch();
}

No comments:

Post a Comment