The first step of my project says to write a function named IsPrime which accepts one integer parameter, say x. Have the function return TRUE if x is prime. Otherwise, have it return FALSE.
Here is the code I have written:
CODE
// Project 4 step 1a
//
#include "stdafx.h"
#include "math.h"
#define TRUE 1
#define FALSE 0
int isPrime ( int );
void main(void)
{
int num1;
printf ( "1 means TRUE, 0 means FALSE\n\n");
printf ( "Please enter a number to check if it is prime: ");
scanf ( "%d", &num1);
printf ( "%d\n\n" , isPrime (num1) );
}
int isPrime(int x)
{
if ( (x%2==0 ) )
return TRUE;
else
return FALSE;
}
Now the next step says:
Write a program that keeps asking the user for an integer say k. As long as k is greater than 0, the program will call isPrime to see if k is a prime. Print the message "Prime" if it is and "Not Prime" if not.
I'm not really worried about the while loop, in fact, if I didn't have to write a function (isPrime), I would be able to do this pretty simple. But I'm just now learning for the first time how to write functions. I'm not sure what to do, I keep messing around with my code changing TRUE and FALSE to Prime and Not Prime. It seems I can only return numbers. What would help me figure out this problem? Any tips or advice to reach the solution are greatly appreciated

.
Your Noob,
Adot2the