Course C Initial 12nd – Exercises with Switch


Now, do these Algorithms using switch command.
1- Make an algorithm that works as a game, it may ask to user “What’s United Kingdom Capital?” so the user will have available 4 possibility, they’re respectively a) Manchester, b) Newcastle, c) London, d) Liverpool, after will be tested them. Note: use for store the result, a character type variable.
  • Case ‘c’, so printf (“You’re Wright”);
  • default, so printf (“You’re wrong”);
2- Make an algorithm that reserves the product code and the quantity, so calculate the prices. Note: before defines how you can see below:
  • M’ – Milk – U$ 1,00 1L.
  • P’ – Potato – U$ 2,50 Kg.
  • E’ – Meat – U$ 10,00 Kg.
  • J’ – Juice – U$ 0,50 each.
Use switch structure, for invalid values, use default to show a note at display. After multiple the price by quantity and print the total price.
3- Make an algorithm that works how a calculator. Use a char variable to store the operator and so make the operation and show at display. Don’t forget to use default for invalid cases.
4- Make an algorithm that calculate the sum between 74 and 8, so show it.
5- Make an algorithm that reserves 1 note and analyze:
  • 0 to 5 – You need study more than you studied!
  • 6 – You need study more!
  • 7 – You have made the required!
  • 8 to 9 – You’re with a good performance!
  • 10 – It’s Excellent!


That’s all folks! In the next lesson, we’ll see Loops in C language. Note: this algorithms will be available to download.

See you later folks!

Comentários

More Famous Posts

Course C Initial 7th – Training with Math

Course C Initial – 3rd Variables Part. 1

Course Python For Life 3 – Input Command