Skip to content

CPRF-Session2/Assignment5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

Assignment 5

Objectives

To gain experience writing functions and using recursion.

Part 1

  1. Write a program three.c that takes in 3 user-input integers and checks whether or not the 3 integers form a valid triangle (no one side is longer than the sum of the other 2 sides). It should contain the following functions:

    • isTriangle(), which determines whether the integers form a valid triangle
    • triangleType(), which determines whether the triangle is equilateral (all sides are equal), isoceles (only 2 sides are equal), or scalene (no sides are equal) and prints a message as appropriate
    • sanitizedInput(), which ensures that the user-input integers are valid
  2. Write a program palindrome.c using recursion to test if a word/phrase is a palindrome (something that reads the same if the letters are reversed, such as racecar).

Part 2

In a text file assignment5.txt, answer the following questions:

  1. What do each of the following mean? Include a description of the syntax or an example.

    • Passing by value:
    • Passing by reference:
  2. What is the function of the return statement in C?

  3. What is the purpose of writing functions?

Submission Guidelines

Please include your name and a description in a comment at the top of your code files. Please also include your name at the top of your assignment5.txt file.

All files must be submitted via GitHub by 10:10am 7/29.

Releases

No releases published

Packages

No packages published