79441892

Date: 2025-02-15 16:42:40
Score: 0.5
Natty:
Report link

#include <stdio.h>

int main() {

int max, x, n = 2; //init variables

printf("Enter max number: ");

scanf("%i", &max);

                    /*prints prime numbers while the max value
                       is greater than the number being checked*/

do {

   x = 0;           //using x as a flag

for (int i = 2; i <= (n / 2); i++) 

{

   if (n % i == 0) 

{

        x = 1;

        break;
    }
}

if (x == 0)     //if n is prime, print it!
    
   printf("the no %i is prime\n", n);

 else

    printf("the no %i is not prime\n", n);

     n++;        //increase number to check for prime-ness

}

while (n < max);


return 0;

}

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: user29658378