Skip to content

Latest commit

 

History

History
23 lines (22 loc) · 2.04 KB

File metadata and controls

23 lines (22 loc) · 2.04 KB

Conditional Statements

  1. Write an if statement that examines two integer variables and exchanges their values if the first one is greater than the second one.
  • Write a program that shows the sign (+ or -) of the product of three real numbers without calculating it. Use a sequence of if statements.
  • Write a program that finds the biggest of three integers using nested if statements.
  • Sort 3 real values in descending order using nested if statements.
  • Write a program that asks for a digit and depending on the input shows the name of that digit (in English) using a switch statement.
  • Write a program that enters the coefficients a, b and c of a quadratic equation ax2+bx+c=0 and calculates and prints its real roots. Note that quadratic equations may have 0, 1 or 2 real roots.
  • Write a program that finds the greatest of given 5 variables.
  • Write a program that, depending on the user's choice inputs int, double or string variable. If the variable is integer or double, increases it with 1. If the variable is string, appends * at its end. The program must show the value of that variable as a console output. Use switch statement.
  • We are given 5 integers. Write a program that checks if the sum of some subset of them is 0. Example: 3, -2, 1, 1, 8 -> 1+1-2=0.
  • Write a program that applies bonus scores to given scores in the range [1, 9]. The program reads a digit as an input.
    • If the digit is between 1 and 3, the program multiplies it by 10
    • If it is between 4 and 6, multiplies it by 100
    • If it is between 7 and 9, multiplies it by 1000
    • If it is zero or if the value is not a digit, the program must report an error Use a switch statement and at the end print the calculated new value in the console.
  • *Write a program that converts a number in the range [0...999] to a text corresponding to its English pronunciation. Examples:
    • 0 -> "Zero"
    • 273 -> "Two hundred and seventy-three"
    • 400 -> "Four hundred"
    • 501 -> "Five hundred and one"
    • 711 -> "Seven hundred and eleven"