Complete the code to check if a number is less than 2, which means it is not prime.
if (num [1] 2) { return false; }
If the number is less than 2, it is not prime.
Complete the for loop to check divisors from 2 up to the square root of the number.
for (int i = 2; i * i [1] num; i++) { if (num % i == 0) { return false; } }
The loop should run while i squared is less than or equal to num.
Fix the error in the if condition that checks divisibility.
if (num [1] i == 0) { return false; }
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] isPrime(int num) { [2]; }
The function returns a boolean value, so use 'bool' as return type and 'return true' if no divisor found.
Fill all three blanks to complete the prime check function with input and output.
#include <iostream> int main() { int num; std::cin >> [1]; if (isPrime([2])) { std::cout << [3] << std::endl; } else { std::cout << "Not prime" << std::endl; } return 0; }
Read input into 'num', check isPrime(num), and print "Prime" if true.
