I, _______, declare that I have completed this assignment completely and entirely on my own, without any unathorized consultation from others or unathorized access to online websites. I have read the UAB Academic Honor Code and understand that any breach of the UAB Academic Honor Code may result in severe penalties.
Student Signature/Initials: ____________
Date: ____________
Write a program in C to check if a number is prime (feel free to utilize https://en.wikipedia.org/wiki/Prime_number).
-
Define a integer variable givenNumber.
-
Use the scanf() function to read the integer variable givenNumber.
-
Use if-conditional statements to find out if givenNumber is prime.
-
Based on the result, print "The given number is prime." or "The given number is not prime.".
-
Utilize the sqrt() function from the math.h header file in your solution.
-
Consider some edge cases (e.g. user gives a floating point number). Respond appropriately to each.
-
If you have not, create a function 'checkIfPrime'. Move your code to it, and call it in the main function.
-
Make 'checkIfPrime' a recursive function 'recursiveCheckIfPrime' that checks if a number is prime.