Exercise
Multiply using variables
Objetive
Write a C# program to print the result of multiplying two numbers which will entered by the user.
Example Code
using System; // Importing the System namespace to use Console functionalities
// Main class of the program
public class Program
{
// Main method where the program execution begins
static void Main()
{
// Declaring two variables to store the numbers entered by the user
double num1, num2;
// Asking the user to enter the first number and reading the input
Console.Write("Enter the first number: ");
num1 = Convert.ToDouble(Console.ReadLine());
// Asking the user to enter the second number and reading the input
Console.Write("Enter the second number: ");
num2 = Convert.ToDouble(Console.ReadLine());
// Calculating the result of multiplying the two numbers
double result = num1 * num2;
// Printing the result of the multiplication to the screen
Console.WriteLine("The result of multiplying the two numbers is: " + result);
}
}