Q:

Write a program in C# Sharp to print the name of the first three letters of month of a year starting form current date

0

Write a program in C# Sharp to print the name of the first three letters of month of a year starting form current date. 
Expected Output :

 The twelve months are :
 Sep
 Oct    
 Nov    
 Dec    
 Jan   
 Feb   
 Mar   
 Apr  
 May   
 Jun 
 Jul   
 Aug 

All Answers

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

using System;

class dttimeex50
{
    static void Main()
    {
    Console.Write("\n\n Display the name of the first three letters of month of a year :\n");
	Console.Write("---------------------------------------------------------------------\n");
	DateTime now = DateTime.Now;
	Console.WriteLine(" The date of Today : {0}",now.ToString("dd/MM/yyyy"));
	Console.WriteLine(" The twelve months are :");
	for (int i = 0; i < 12; i++)
	{
	    Console.WriteLine(" {0}",now.ToString("MMM"));
	    now = now.AddMonths(1);
	}
	Console.WriteLine();
    }
}

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