Assignment 1

Important dates

Assigned16 May 2018 @ 11:36h
Due18 May 2018 @ 11:59h


Write a C++ function that evaluates quadratic expressions.

A quadratic expression is one of the form:

$ a x^2 + b x + c $

Given values for $a$, $b$, $c$ and $x$, you can evaluate this expression and turn it into a number. Your goal for this assignment is to write a definition for a C++ function corresponding to the following declaration:

double quadraticEvaluate(double a, double b, double c, double x);

Start by asking yourself: how would I solve this problem mathematically? Before you write any C++ code, work through a few examples on paper and note the way in which you solve the problem. This is your (admittedly rather simple) algorithm. That’s what you need to turn into C++ code.

Next, ask yourself: how could you check that this function works? I would suggest writing a little bit of test code within a main function that calls quadraticEvaluate and lets you check its correctness. Then, after writing the test code, add a definition for the function. Finally, submit the result as a file called assign1.cpp in the Brightspace/D2L dropbox for assignment 1.

Remember, assignments are individual work: you must complete the assignment yourself.