The computer can also do regular math that you see in school. Use
Console.WriteLine to print out the result from the math expressions. No quotation marks are needed for numbers!
Console.WriteLine(5 + 4); Console.WriteLine(6 * (9 - 7) / 3);
Here is the full list of math symbols that you can use:
Fun Fact: Computer Division
The computer does division differently from your regular calculator. Computer division will exclude remainders or decimals. For example,
15 / 4 produces
3, and not
Try printing out the answers to the following to the console. Ensure your brackets are matched. Use a calculator (or mental math) to verify the computer produced the correct answer.
2 - 19
(3 + 5) * 6
(13 + 5 * 8) / (6 - (3 + 7))
Fun Fact: Random Numbers
Here is how to print a random number between
1 (inclusive) and
Random random = new Random(); Console.WriteLine(random.Next(1, 10));
Try to find where we use
Random in the GuessTheWord game! However, the details as to how this works is complicated, so we will skip this discussion.