Tuesday, 13 October 2015

Write a program in C# which accepts user’s details as name, city, age and pin number. Then store all the values in the variable and then print all the information in correct format.

using System;
class Program
{
    public static void Main()
    {
        string Name;
        string city;
        int age;
        int Pincode;

        Console.WriteLine("Please Enter your name");
        Name = Console.ReadLine();

        Console.WriteLine("Please Enter your city");
        city = Console.ReadLine();

        Console.WriteLine("Please Enter your age");
        age = int.Parse(Console.ReadLine());

        Console.WriteLine("Please enter your pin code");
        Pincode = Convert.ToInt32(Console.ReadLine());

        Console.WriteLine("\nYour Complete Address");
        Console.WriteLine("Name     = {0}", Name);
        Console.WriteLine("City     = {0}", city);
        Console.WriteLine("Age      = {0}",age);
        Console.WriteLine("Pin Code = {0}", Pincode);
    }
}

No comments:

Post a Comment