My instructions were to write a C# program to print on screen the output of adding, subtracting, multiplying and dividing of two numbers which will be entered by the user.
The lines of code below seemed to be the simplest way to input values and print them out. Is {0} + {1} = {2}
an expression innately built into C#? I'm not sure how num1 and num2 are being picked up as 0 and 1 in this instance and the answer as 2.
Console.Write("Enter a number: ");
int num1= Convert.ToInt32(Console.ReadLine());
Console.Write("Enter another number: ");
int num2= Convert.ToInt32(Console.ReadLine());
Console.WriteLine("{0} + {1} = {2}", num1, num2, num1+num2);
Console.WriteLine("{0} - {1} = {2}", num1, num2, num1-num2);
Console.WriteLine("{0} x {1} = {2}", num1, num2, num1*num2);
Console.WriteLine("{0} / {1} = {2}", num1, num2, num1/num2);
Console.WriteLine("{0} mod {1} = {2}", num1, num2, num1%num2);
//10 + 2 = 12
//10 - 2 = 8
//10 x 2 = 20
//10 / 2 = 5
//10 mod 2 = 0