WRITE A C PROGRAM TO CHECK THAT INPUT NUMBER IS PRIME OR NOT - Code

Latest

programs

Sunday, October 30, 2011

WRITE A C PROGRAM TO CHECK THAT INPUT NUMBER IS PRIME OR NOT


WRITE A PROGRAM TO CHECK THAT INPUT NUMBER IS PRIME OR NOT


#include<stdio.h>
#include<conio.h>
void main( )
{
int num, i;
clrscr( ) ;
printf(“”\n enter a no.”) ;
scanf(“%d”, & num) ;
i=2 ;
While(I<=(num-1))
{
if(num % I= =0)
{
printf(“not a prime no.”);
break ;
}
I++ ;
}
if(i = = num)
printf(“prime number”);
getch();
}

1 comment: