Complete the code to check if a number is less than 2, which is not prime.
if (num [1] 2) { printf("Not prime\n"); return 0; }
Numbers less than 2 are not prime, so we check if num is less than 2.
Complete the for loop to check divisors from 2 up to the square root of num.
for (int i = 2; i [1] num / i; i++) { if (num % i == 0) { printf("Not prime\n"); return 0; } }
The loop runs while i is less than or equal to the square root of num, so i <= num / i. The condition uses '<=' to continue looping.
Fix the error in the if condition to correctly check if num is divisible by i.
if (num [1] i == 0) { printf("Not prime\n"); return 0; }
The modulus operator '%' checks if num is divisible by i with no remainder.
Fill both blanks to complete the function header and return type for checking prime.
[1] is_prime(int num) { if (num < 2) { return [2]; } // rest of code }
The function returns an int indicating true (1) or false (0). If num is less than 2, it returns 0 (not prime).
Fill all three blanks to complete the return statement that confirms the number is prime.
return [1]; // Usage example: // if (is_prime([2])) { // printf("%d is prime\n", [3]); // }
Return 1 to indicate prime. Use 'num' in the usage example to check and print the number.
