1.06: Use of {0} and comments

OBJECTIVE

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: 

Enter the first number to multiply 
12 
Enter the second number to multiply 
23 
Enter the third number to multiply 

RESOLUTION

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace My3Development
{
public class UseOfcomments
{
    public static void Main(String[] args)
    {
        int number1;
        int number2;
        int number3;

         Console.Write("Enter the first number to multiply\t: ");
         number1 = Convert.ToInt32(Console.ReadLine());

         Console.Write("Enter the second number to multiply\t: ");
         number2 = Convert.ToInt32(Console.ReadLine());

         Console.Write("Enter the third number to multiply\t: ");
         number3 = Convert.ToInt32(Console.ReadLine());

         int result = number1 * number2 * number3;
         
         Console.WriteLine("Result: {0} x {1} x {2} = {3}",
                        number1, number2, number3, result);

         Console.ReadKey();

        }
    }
 }

DEMO RESULT


         PREVIOUS                                             HOME                                                NEXT

0 comments :

Please Enter best of your Comments