F Program to find the given number Prime or not in C program | CodeTheta

Program to find the given number Prime or not in C program

January 18, 2014


/* http://native-code.blogspot.com */

#include<stdio.h>
#include<conio.h>

void main()
{
 int x,i;
 printf("/* http://native-code.blogspot.com */\n\n\t Enter a number...");
 scanf("%d",&x);

 i=2;

 while(i<=x-1)
 {
  if(x%i==0)
  {
   printf("\n\n\t Not prime !!!");
   break;
  }
  i++;
 }

 if(i==x)
 printf("\n\n\t Prime !!!");

 getch();
}
/* http://native-code.blogspot.com */

Post a Comment