Auto AdSense

Tuesday 4 November 2014

C Program to determine whether the number is prime or not

  #include <stdio.h>
  #include <conio.h>
  Int main()
  {
    int i,j=2,ch=0;
    clrscr();
    printf("\nENTER ANY NUMBER");
    scanf("%d",& i);
    while(j < =i/2)
    {
        if(i%j==0)
        {
            printf("%d IS NOT PRIME",i);
            ch=1;
            break;
        }
        else
        {
            j++;
        }
    }
    if(ch==0)
    {
          printf("%d IS PRIME",i);
      }
  }      

No comments:

Post a Comment