About Me

My photo
Raipur, Chhattisgarh, India
Hi , I am Amit Thakur. I have worked as a QA Engineer for two years and as a Java Developer for one year in NIHILENT TECHNOLOGIES PVT. LTD., Pune.Currently I am working as DEAN (Research & Development) in Bhilai Institute of Technology, Raipur.

Monday, September 2, 2013

Check Whether Number is Prime or not

#include<stdio.h>
int main()
{
    int num,i,count=0;
    printf("Enter a number:");
    scanf("%d",&num);
    for(i=2;i<=num/2;i++){
        if(num%i==0){
         count++;
            break;
        }
    }
   if(count==0)
        printf("%d is a prime number",num);
   else
      printf("%d is not a prime number",num);
   return 0;
}

No comments: