w3resource logo
C# Sharp Programming Exercises

C# Sharp Exercises: Determine the day of the week 40 days after the current date

C# Sharp DateTime: Exercise-10 with Solution

Write C# Sharp program to determine the day of the week 40 days after the current date.

Sample Solution:-

C# Sharp Code:

using System;
public class Example10
{
   public static void Main()
   {
      
    // Calculate what day of the week is 40 days from this instant.
    	DateTime today = DateTime.Now;
		DateTime answer = today.AddDays(40);
        Console.WriteLine("Today: {0:dddd}", today);
        Console.WriteLine("40 days from today: {0:dddd}", answer);
   }
}

Sample Output:

Today: Saturday                                                                                               
40 days from today: Thursday 

C# Sharp Code Editor:

using System;
public class Example10
{
   public static void Main()
   {
      
    // Calculate what day of the week is 40 days from this instant.
    	DateTime today = DateTime.Now;
		DateTime answer = today.AddDays(40);
        Console.WriteLine("Today: {0:dddd}", today);
        Console.WriteLine("40 days from today: {0:dddd}", answer);
   }
}

Improve this sample solution and post your code through Disqus