Example
Let's try to write a calculator for prime numbers.
Our task is to display some arithmetic expression on the screen and make the computer calculate it.
For example:
5+7=12
Moreover, instead of 5 and 7, there can be different numbers, depending on the values of the variables
a
and
b
in the program.
In the output statement, you can display not just text, but also the values of variables, as well as the result of an arithmetic expression. Moreover, the output sequence may be different. For example, in order to display the above expression, you need to write it like this:
Console.WriteLine(a + "+" + b + "=" + (a+b));
If we want to display the value of a variable, then we just need to specify its name without quotes. If we want to display the result of an arithmetic expression, then it is enough to simply write the arithmetic expression correctly. Please note:
Variables and text are separated from each other by the "
+
" operator, while the text is written in quotes, and variables without them.