Monday, 4 June 2018

How to write program to determine whether a number is prime or not in c

/* program to check prime or not */
# include <stdio.h>
void main ()
int num, counter ;
printf ("\n Enter a number:") ;
scanf ("%d", &num)
counter = 2 ;
while (counter <= num-1)
{
if (num % counter == 0)
{
printf ("\n Not a prime number:") ;
break ;
}
counter++ ;
}
if (counter == num)
printf ("\n prime number:") ;
getch () ;
}

No comments:

Post a Comment

Featured post

Kalgudi Interview Round!!

Those who cleared the second round of kalgudi got an email from exceller to complete their Kalgudi Interview Round. So here we will discuss ...