C++ Lab Exercises
C++ Lab Exercises
1. Write a C++ program to find the roots of a quadratic equation ax^2 + bx + c = 0. Prompt
the user to enter the values of coefficients 'a', 'b', and 'c'. Calculate the discriminant (Δ)
using the formula Δ = b^2 - 4ac and then find the roots using the quadratic formula
2. Write a C++ program that prompts the user to input a temperature in Fahrenheit and then
Exercises 2
2. Write the programs the user to enter a number, and then uses awhile loop to reverse the
digits of the number. Finally, it compares the original number with its reversed version to
3. Write the c++ program it calculate the harmonic series of n numbers and sum of harmonic
**
***
****
***
**
*
Exercises 3
1. Write a C++ array program it input student [20], Name [20], and mark[20] after
input two strings, and then compare them to determine if they are equal or if one string is
greater than the other. Display an appropriate message based on the comparison result.
3. Write a C++ program to reverse a string entered by the user. Prompt the user to input a
string, and then reverse the order of its characters. Display the original and reversed
strings.