Exercise
Use of {0} and comments
Objetive
Write a C# program to ask the user for three numbers and display their multiplication. The first line must be a comment with your name and surname. It MUST look as follows:
// Your Name and Surname
Enter the first number to multiply:
12
Enter the second number to multiply:
23
Enter the third number to multiply:
2
Example Code
using System; // Importing the System namespace to use Console functionalities
// Main class of the programpublic
class Program
{
// Main method where the program execution begins
static void Main()
{
// Declaring three variables to store the numbers entered by the user
double num1, num2, num3;
// Asking the user to enter the first number and reading the input
Console.Write("Enter the first number to multiply: ");
num1 = Convert.ToDouble(Console.ReadLine());
// Asking the user to enter the second number and reading the input
Console.Write("Enter the second number to multiply: ");
num2 = Convert.ToDouble(Console.ReadLine());
// Asking the user to enter the third number and reading the input
Console.Write("Enter the third number to multiply: ");
num3 = Convert.ToDouble(Console.ReadLine());
// Calculating the result of multiplying the three numbers
double result = num1 * num2 * num3;
// Printing the result of the multiplication to the screen using {0}
Console.WriteLine("The result of multiplying the three numbers is: {0}", result);
}
}