Q:

Write a C# Sharp program to add specified number of months (between zero and fifteen months) to the last day of August, 2016

0

Write a C# Sharp program to add specified number of months (between zero and fifteen months) to the last day of August, 2016. 

Expected Output :

8/31/2016                                                               
9/30/2016                                                               
10/31/2016                                                              
11/30/2016                                                              
12/31/2016                                                              
1/31/2017                                                               
2/28/2017                                                               
3/31/2017                                                               
4/30/2017                                                               
5/31/2017                                                               
6/30/2017                                                               
7/31/2017                                                               
8/31/2017                                                               
9/30/2017                                                               
10/31/2017

11/30/2017

All Answers

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

using System;
public class Example14
{
   public static void Main()
   {
      var dat = new DateTime(2016, 8, 31);
      for (int ctr = 0; ctr <= 15; ctr++)
         Console.WriteLine(dat.AddMonths(ctr).ToString("d"));
   }
}

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