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.

Expected Output :

Today: Saturday                                                         
40 days from today: Thursday 

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);
   }
}

C# Sharp Practice online:

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.



Join our Question Answer community to learn and share your programming knowledge.

Solve these problems:

Python: How to check whether a file exists using Python?

C#: Loops in c#

PHP: For each

SQL: JOIN using more than 5 tables

JavaScript: Blank Slide in Javascript Slideshow