0% found this document useful (0 votes)
7 views12 pages

Examples 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views12 pages

Examples 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Selection Exercise

QUADRATIC EQUATION
SOLUTION
QUADRATIC EQUATION
SOLUTION
1. Start

2. Input Values: Prompt the user to enter values for a, b, and c.

3. Calculate Discriminant: Compute discriminant = b² - 4ac.

4. Check Discriminant:

- If discriminant > 0:

- Calculate r1 = (-b + sqrt(discriminant)) / (2a)

- Calculate r2 = (-b - sqrt(discriminant)) / (2a)

- Display 'The equation has two real roots: r1 and r2'

- Else if discriminant == 0:

- Calculate r = -b / (2a)

- Display 'The equation has one real root: r'

- Else (discriminant < 0):

- Display 'The equation has no real roots.'

5. End
QUADRATIC EQUATION
SOLUTION
Test Cases:
•, ( a=1, b=−5, c=6 ), solution: x=3 and x=2
•, (a = 2 , b = 4 , c = -6) , solution: x=1 and x=−3
• (a = 1 , b = 4 , c = 5) , No solution.
• (a = 1 , b = -6 , c = 9) , only one root.

https://onlinegdb.com/FoUz9pEls
Solve 2 * 2 linear equations
Solve 2 * 2 linear equations
Solution steps:
1. Prompt the user to enter values for a, b, c, d, e, and f.
2. Compute the determinant
3. Check if Determinant is Zero:
- Yes: Output "The equation has no solution" and go to End.
- No: Proceed to the next step.
4. Calculate Values for 𝑥 and 𝑦:

5. Display the values of 𝑥 and 𝑦. https://onlinegdb.com/DxHHoeuec


Number Prediction
Number Prediction
Solution steps:
1. Two digits random Number Generation.
2. The program prompts the user to input their predicted two-digit integer.
3. Digit Extraction.
4. Accuracy Determination.
5. Result Display.

https://onlinegdb.com/7anx6hs2Y
Check ISBN-10
Check ISBN-10
Solution steps:
1. Ask the user to enter the first 9 digits of ISBN.
2. Extract each digit from the given number.
3. Calculate the last digit checksum.
4. Check if the last digit equal to 10, if true add X to last digit, else add the last digit to the
number.

https://onlinegdb.com/VXRa3EG7F
Palindrome number

https://onlinegdb.com/i7x3_yBtZ
Financial: compare costs

https://onlinegdb.com/syNLNYgVk

You might also like