Practical No.: 01: AIM: Write A Console Application That Obtains Four Int Values From The User and Displays The
Practical No.: 01: AIM: Write A Console Application That Obtains Four Int Values From The User and Displays The
: 01
AIM: Write a console application that obtains four int values from the user and displays the
product.
Hint: you may recall that the Convert.ToDouble() command was used to convert the input from
the console to a double; the equivalent command to convert from a string to an int is
Convert.ToInt32().
CODE:
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int num1, num2,num3,num4,prod;
Console.Write("Enter number 1: "); num1 =
Int32.Parse(Console.ReadLine());
Console.Write("Enter number 2: ");
num2 = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter number 3: ");
num3 = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter number 4: ");
num4 = Convert.ToInt32(Console.ReadLine());
prod = num1 * num2 * num3 * num4;
Console.WriteLine(num1 + "*" + num2 + "*" + num3 + "*" + num4 + "=" + prod);
}
}
}
OUTPUT:
Enter number 1: 6
Enter number 2: 5
Enter number 3: 4
Enter number 4: 3
6*5*4*3=360