+ 1

# I have difficulty with this problem

Write a C++ program to evaluate the velocity, v. Do not use the in-built math functions from C++ library, for example, do not use the inbuilt square root function (write your own code that computes the square root). Prompt the user for 𝑣0, 𝑎, 𝑥, 𝑎𝑛𝑑 𝑥0 values and print the result on the screen. Your program should consist of functions to carry out the following: i) compute squares (f_squares) ii) compute square root (f_sqrt) iii) compute sum (f_sum) iv) compute difference (f_diff). 𝑣 = √𝑣02 + 2𝑎(𝑥 − 𝑥0)

4 Answers

+ 3

Emerson Prado Would you consider the plus and minus operators as "math function"? To me the task reads as if they should focus on implementing a sqrt function, not like redefining the language 🤔

+ 2

What exactly is the difficulty? Could you please link your code attempt?
You could start by getting input and defining the square function...

+ 1

Lisa Well, the task asks for functions "sum" and "difference". Using "+" and "-", I think there's no learning point in writing a function.

0

i) Just think on the definition of square (the operation, not the shape) and you're ready.
ii) Search for square root calculation algorithms. Usually, one uses an iterative formula.
iii and iv) The only possibility I can think of is going for binary operations with booleans and shifts.