Skip to content

Exercises from book "Fundamentals of Computer Programming with C#" Exercise 5: Conditional Statements

Notifications You must be signed in to change notification settings

MiroM73/ConditionalStatements

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ConditionalStatements

Exercises from book "Fundamentals of Computer Programming with C#" Exercise 5: Conditional Statements

  1. Write an if-statement that takes two integer variables and exchanges their values if the first one is greater than the second one.

  2. Write a program that shows the sign (+ or -) of the product of three real numbers, without calculating it. Use a sequence of if operators.

  3. Write a program that finds the biggest of three integers, using nested if statements.

  4. Sort 3 real numbers in descending order. Use nested if statements.

  5. Write a program that asks for a digit (0-9), and depending on the input, shows the digit as a word (in English). Use a switch statement.

  6. Write a program that gets the coefficients a, b and c of a quadratic equation: ax2 + bx + c, calculates and prints its real roots (if they exist). Quadratic equations may have 0, 1 or 2 real roots.

  7. Write a program that finds the greatest of given 5 numbers.

  8. Write a program that, depending on the user’s choice, inputs int, double or string variable. If the variable is int or double, the program increases it by 1. If the variable is a string, the program appends "*" at the end. Print the result at the console. Use switch statement.

  9. We are given 5 integer numbers. Write a program that finds those subsets whose sum is 0. Examples:

  • If we are given the numbers {3, -2, 1, 1, 8}, the sum of -2, 1 and 1 is 0.
  • If we are given the numbers {3, 1, -7, 35, 22}, there are no subsets with sum 0.
  1. Write a program that applies bonus points to given scores in the range [1…9] by the following rules:
  • If the score is between 1 and 3, the program multiplies it by 10.
  • If the score is between 4 and 6, the program multiplies it by 100.
  • If the score is between 7 and 9, the program multiplies it by 1000.
  • If the score is 0 or more than 9, the program prints an error message.
  1. * Write a program that converts a number in the range [0…999] to words, corresponding to the English pronunciation. Examples:
  • 0 --> "Zero"
  • 12 --> "Twelve"
  • 98 --> "Ninety eight"
  • 273 --> "Two hundred seventy three"
  • 400 --> "Four hundred"
  • 501 --> "Five hundred and one"
  • 711 --> "Seven hundred and eleven"

About

Exercises from book "Fundamentals of Computer Programming with C#" Exercise 5: Conditional Statements

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages