Skip to content

shanroxalot/Lab-01

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lab-01: Basic Linux Commands/Intro to C

Name:

Honor Code:

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: ____________

Assignment:

Write a program in C to check if a number is prime (feel free to utilize https://en.wikipedia.org/wiki/Prime_number).

  1. Define a integer variable givenNumber.

  2. Use the scanf() function to read the integer variable givenNumber.

  3. Use if-conditional statements to find out if givenNumber is prime.

  4. Based on the result, print "The given number is prime." or "The given number is not prime.".

Optional:

  • 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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C 100.0%