w3resource logo


C# Sharp Programming Exercises

C# Sharp Exercises: Calculate the specified day of the week


C# Sharp DateTime : Exercise-9 with Solution

Write a C# Sharp program to calculate what day of the week is 40 days from this moment.

Expected Output :

Today = 8/20/2016 4:18:17 PM                                            
Thursday 

C# Sharp Code:

using System;
public class Example9
{
   public static void Main()
   {
      
    System.DateTime today = System.DateTime.Now;
    System.Console.WriteLine("Today = "+System.DateTime.Now);
    System.TimeSpan duration = new System.TimeSpan(40, 0, 0, 0);
    System.DateTime answer = today.Add(duration);
    System.Console.WriteLine("{0:dddd}", answer);
   }
}

C# Sharp Practice online:

using System;
public class Example9
{
   public static void Main()
   {
      
    System.DateTime today = System.DateTime.Now;
    System.Console.WriteLine("Today = "+System.DateTime.Now);
    System.TimeSpan duration = new System.TimeSpan(40, 0, 0, 0);
    System.DateTime answer = today.Add(duration);
    System.Console.WriteLine("{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.

Help the community:

Python: Fizzbuzz

C++: Decimal to binary conversion

JavaScript: Need Help in JavaScript

Python: Help me with this program