Question 1:
Write the pseudo code of an algorithm that searches from a given number entered by the user in a set of 100 numbers.
The algorithm should print the position of the number in the set, if found; otherwise, it prints that the given number
is not found in the set.
Question 2:
Provide a C++ code segment for the following piecewise function:
\begin{cases}
3x + 5 & -20 \le x < -10 \\
x^2 - 4x + 7 & -10 \le x < 0 \\
\sqrt{x} + 1 & 0 \le x < 12 \\
\sin(2x) & 12 \le x < 20
\end{cases}
Question 3:
Newton's law of gravitational force between two masses $M_1$ and $M_2$ with a distance $d$ between them is given by the
following equation:
$F = G \frac{M_1 M_2}{d}$
where G is the gravitational constant and its value is:
$G = 6.67 \times 10^{-11} \frac{m^3}{kg \cdot s^2}$
Write a C++ program that asks the user to provide the values of the two masses and the distance between them and
calculates the force between them. The program prints the value of the force on screen using scientific notation and
up to four decimal places.
Question 4:
The quadratic equation is given by the following formula:
$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$
Write a C++ program that computes the roots of a quadratic equation. The program should determine whether the
roots are real, imaginary or equal.
1. If the roots are real, the program should print both roots of the equation
2. If the roots are equal, the program will print the only root
3. If the roots are imaginary, the program will print the real and imaginary parts of both roots. The real part is
computed as $\frac{-b}{2a}$ whereas the imaginary part is calculated as $\frac{\sqrt{-discriminant}}{2a}$
The program gets the values of a, b and c from the user.