If - else Practice problems ---------------------------- Problem 1: int x = 0; int y = 20; bool z = true; bool w = false; bool result = (!w || z) && !((y > x) && (!z)); //true Problem 2: Write a program that finds all roots of the quadratic equation. Quadratic equation: (-b + squareroot(b*b - 4*a*c))/ (2*a) and (-b - squareroot(b*b - 4*a*c))/ (2*a) A quadratic equation can have either one or two real or complex roots depending on the discriminant of the equation The discriminant is the part under the square root sign there are 3 cases for the roots based on the discriminant case 1: if the discriminant is positive if the discriminant is zero if the discriminant is negative if discriminant > 0 float a, b, c; float root1, root2, imaginary; float discriminant; cout << "Enter values of a, b, c of quadratic equation (aX^2 + bX + c): "; cin >> a >> b >> c; discriminant = (b*b) - (4*a*c); if(discriminant > 0) { root1 = (-b + sqrt(discriminant)) / (2*a); root2 = (-b - sqrt(discriminant)) / (2*a); cout << "Two distinct and real roots exists: " << root1 << " and " << root2; } else if(discriminant == 0) { root1 = -b / (2*a); root2 = root1; cout << "Two equal and real roots exists: " << root1 << " and " << root2; } else { root1 = root2 = -b / (2*a); imaginary = sqrt(-discriminant) / (2*a); cout << "Two distinct complex roots exists: " << root1 << " + i” << imaginary << " and "<< root2 << " - i”<< imaginary; } Problem 3: Write a program that enters a number and prints out whether it's even or odd. Use a switch statement for this. int number = 0; cout << "Enter any number to check even or odd: "; cin >> number; int result = number % 2; switch(result) { //If n%2 == 0 case 0: cout << "Number is Even"; break; //Else if n%2 != 0 case 1: cout << "Number is Odd"; break; }