11.Check prime number using do while loop
#include <stdio.h>
int main()
{
int num, prime = 1;
int i = 2;
printf("Enter a number :");
scanf("%d", &num);
do
{
if(num==2)
break;
if (num % i == 0)
prime = 0;
i++;
}
while (num > i);
{
if (prime == 0)
{
printf("\n\nThis is not a prime number :");
}
else
{
printf("\n\nThis is Prime number :");
}
}
return 0;
}
Comments
Post a Comment