QUESTION:- for loop to print prime number
#include <stdio.h>
// author: all programming solution
void main()
{
int n, b = 0;
printf("enter a numeber to find prime number: ");
scanf("%d", &n);
for (int i = 1; i <= n / 2; i++)
{
if (n % 2 == 0)
{
b++;
break;
}
}
if (b == 0 && n != 1)
{
printf("%d is prime number !", n);
}
else
{
printf("%d is not a prime number!", n);
}
}
OUTPUT
enter a number to find a prime number: 4
4 is not a prime number!
0 Comments