Q:

Write a program in C# Sharp to check whether the given year, month and day are the current or not

0

Write a program in C# Sharp to check whether the given year, month and day are the current or not. 
Test Data :
Input the Day : 17
Input the Month : 09
Input the Year : 2016
Expected Output :

The formatted Date is : 17/09/2016
 The current date status : True 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;

class dttimeex43
{
    static void Main()
    {
    int yr, mn, dt;
    
    Console.Write("\n\n Check whether the given year, month and day is the current or not :\n");
	Console.Write("------------------------------------------------------------------------\n");
	
    Console.Write(" Input the Day : ");
    dt = Convert.ToInt32(Console.ReadLine());	
    Console.Write(" Input the Month : ");
    mn = Convert.ToInt32(Console.ReadLine());	
    Console.Write(" Input the Year : ");
    yr = Convert.ToInt32(Console.ReadLine());		
	DateTime value = new DateTime(yr, mn, dt);
	Console.WriteLine(" The formatted Date is : {0}",value.ToString("dd/MM/yyyy"));
	Console.WriteLine(" The current date status : {0}\n",value == DateTime.Today);
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now