1
Programming Fundamentals Assignment-1 (Due 11:55 pm 30/8/15) You will write a C++ program that will perform the following tasks: 1. Prompt the user to enter the coefficients (a, b, c) of a quadratic equation. Variables a, b, c should be double data type. 2. Check if a = 0, then prompt that ‘a’ cannot be 0, re-enter coefficients. 3. Calculate the discriminant and determine if the roots are: a. Real and equal b. Real and unequal c. Imaginary d. Complex 4. Calculate the roots and display them on the screen mentioning one of 3a, 3b, 3c and 3d above. Complex roots should be displayed as x + yi and x – yi where ‘i’ is iota and x, y are values. All results will be displayed to 2 decimal places.

Assignment 1

Embed Size (px)

DESCRIPTION

Programming Fundamentals

Citation preview

Page 1: Assignment 1

Programming Fundamentals

Assignment-1 (Due 11:55 pm 30/8/15)

You will write a C++ program that will perform the following tasks:

1. Prompt the user to enter the coefficients (a, b, c) of a quadratic equation. Variables a, b, c should be double data type.

2. Check if a = 0, then prompt that ‘a’ cannot be 0, re-enter coefficients.3. Calculate the discriminant and determine if the roots are:

a. Real and equalb. Real and unequalc. Imaginaryd. Complex

4. Calculate the roots and display them on the screen mentioning one of 3a, 3b, 3c and 3d above. Complex roots should be displayed as x + yi and x – yi where ‘i’ is iota and x, y are values. All results will be displayed to 2 decimal places.