Exercise: Is the Number Prime

Write code to solve the problem.

Question

Write a function that determines whether an integer isprime. The function should take as input a single integer and return a 1 if the input is prime, and a 0 if it is not.

Sample input:

isPrime(12)
isPrime(17)

Sample output:

0
1

Exercise: Is the Number Prime

Write code to solve the problem.

Question

Write a function that determines whether an integer isprime. The function should take as input a single integer and return a 1 if the input is prime, and a 0 if it is not.

Sample input:

isPrime(12)
isPrime(17)

Sample output:

0
1
C
#include <stdio.h>
int isPrime(int n)
{
// Write your code here...
return -1;
}
int main(void)
{
int n = 10;
printf("%d\n", isPrime(n));
return 0;
}