Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Computer Science II func. assignment #2 This is an example of a function where, (in the function) you read in 3 numbers, do a calculation,

Computer Science II func. assignment #2

This is an example of a function where, (in the function) you read in 3 numbers, do a calculation, and return a value

Write a C function that will:

  1. Determine if you have entered a right triangle
  2. Accept 3 ints (in main)
    1. Length of side one of the triangle
    2. Length of side two of the triangle
    3. Length of side three of the triangle
  3. returns a bool (true or false) whether the 3 lengths entered determines a right triangle
  4. the function does not print out the answer, just returns the answer
  5. answer is printed in main
  6. the three sides of the triangle are printed in the function
  7. the length of the sides are not input in any particular order

function header should be

bool determineRightTri()

in the function

  1. ask for the length of one side of a triangle
  2. read in this length
  3. ask for the length of one the second side of a triangle
  4. read in this length
  5. ask for the length of one the third side of a triangle
  6. read in this length
  7. determine whether this is a right triangle
  8. return true if you have a right triangle, else false

Output should look like the following

??? length of side 1

??? length of side 2

??? length of side 3

is a right triangle

Or

is not a right triangle

these lines are printed in the function

??? length of side 1

??? length of side 2

??? length of side 3

this is printed in main--using the returned Boolean value

is a right triangle

Or

is not a right triangle

Use the output (cout) manipulators to format the output correctly [setw(?), fixed, right, left, etc]

Sacond part

Write a C program that has 1 function:

void giveDays(int days, int weeks)

  1. accepts as parameters two ints. The first is a number of days and the second is a number of weeks
  2. calculates how many total days are represented by the 2 parameters

Example: 25 days and 3 full weeks represents a total number of days of 46

  1. print out (in the function) how many total days are calculated

function headers should be:

void giveDays(int days, int weeks)

in main

  1. ask for the number of days
  2. read in the number of days
  3. ask for the number of weeks
  4. read in the number ofweeks
  5. call your function giveDays(int, int)

output from the function should look like:

??? days

??? weeks

has ??? total days

Use the output (cout) manipulators to format the output correctly [setw(?), fixed, right, left, etc]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions