Search This Blog

Loading...

Write a C Program to check whether the given number is prime or not : GTU Nov-Dec 2010

#include<stdio.h>
#include<conio.h>
void main()
{
 int number,stop=0,i;

 clrscr();
 printf("\n Enter Number : ");
 scanf("%d",&number);
 for(i=2;i<number;i++)
 {
  if( (number%i) == 0)
  {
   stop = 1;
   break;
  }
 }
 if(stop == 1 || number == 0 || number == 1)
  printf("\nNumber is not prime.");
 else
  printf("\nNumber is prime.");
 getch();
}

No comments:

Post a Comment