Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

COMPROG

Computer Programming (OOP)


Laboratory

Activity 3: Mathematical Operators and Functions

Overview: C++ being superset of C, supports large number of useful mathematical


functions. These functions are available in standard C++ and C to support various
mathematical calculations. Instead of focusing on implementation, these
functions can be directly used to simplify code and programs.

At the end of this activity, students will be able create a C++ program that would
perform calculation using c++ built-in mathematical operators.

File Name: Lastname_Act3

Description: A quadratic equation has the form 𝑎𝑥 2 + 𝑏𝑥 + 𝑥 = 0. In this equation, x is the


unknown variable, and a, b, c are known constants.

Examples: 5𝑥 2 + 6𝑥 + 2 = 0 ; a = 5, b = 6, c = 2
𝑥 2 − 7𝑥 + 20 = 0 ; a = 1, b = 7, c = 20
34𝑥 2 + 16 = 0 ; a = 34, b = 0, c =16

The real roots of a quadratic equation can be calculated using quaddratic


formula as:

−𝑏 + √𝑏2 − 4𝑎𝑐
Root 1 =
2𝑎

−b − √𝑏2 − 4𝑎𝑐
Root 2 =
2𝑎

Requirements Create a C++ program that allows user to input for the value of a, b, and c of the
quadratic equation. Compute and display the two roots of the equation

Test Case

You might also like