Program to Detection of a Prime Number


#include
main()
{
int num, i;

printf ("Enter a number:");
scanf ("%d", &num);

i=2;
while (i<=num - 1)

{
if (num % i ==0)

{
printf ("Not a prime number");
break;
}

i++;
}

if (i == num)

printf ("Prime Number");
}

2 comments:

  1. what if dont wanna use break statement?

    ReplyDelete
  2. you can use goto & control the flow of program as you want...

    ReplyDelete