Initial Basics – Algebra – Problem #32

IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive

Difficulty: Hard

Problem Statement

Read three real numbers, i.e., a, b, and c, which represent the coefficients of a quadratic equation and display them in the exact form ax ˆ 2 + bx + c = 0. Hence check whether the roots are real, coincident, or complex according to the rules of quadratic equation and display it. No need to find out the roots separately. Additionally if the roots are complex, determine the quadrant (i.e 1st quadrant/2nd quadrant/3rd quadrant/4th quadrant) of the 2D Argand plane in which the first complex root of the form a + ib lies. Note that complex roots occur as conjugate pairs a+ib and a−ib, consider only the root in the form a+ib and determine in which quadrant it lies. Example1: (Please take the input and display the output as shown) Input: a:5 b:2 c:1 Output: Equation: 5x ˆ 2 + 2x + 1 = 0 Roots: Complex Quadrant of 1st complex root: 2nd [Reason: The first complex root is −0.2 + 0.4i as per the given example, hence it lies in the 2nd quadrant] Example2: (Please take the input and display the output as shown) Input: a:1 b:2 c:-3 Output: Equation: x ˆ 2 + 2x − 3 = 0 Roots: Real

Back to Lab Problems
Initial Basics/Algebra/Problem #32

Lab Problem Statement

Specifications & Problem DetailsIIT Kharagpur PDS Archive
Loading question...

Interactive C Compiler · Problem #32

WASM In-Browser

Runs directly on your machine · Zero remote server dependency

Compiler downloads on first Run (large, saved in your browser after that)
main.cCtrl + Enter to run
1
2
3
4
5
6
7
Input (stdin)given to scanf / cin
Output

Output appears here. Press Run to compile and execute.