w3resource

C#: 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
{
    // Main method, entry point of the program
    public static void Main()
    {
        // Get the current date and time
        DateTime today = DateTime.Now;

        // Calculate the date 40 days from the current date using AddDays method
        DateTime answer = today.AddDays(40);

        // Display the current day of the week
        Console.WriteLine("Today: {0:dddd}", today);

        // Display the day of the week 40 days from today
        Console.WriteLine("40 days from today: {0:dddd}", answer);
    }
}

Sample Output:

Today: Saturday                                                                                               
40 days from today: Thursday 

Flowchart :

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

C# Sharp Code Editor:

Improve this sample solution and post your code through Disqus

Previous: Write a C# Sharp program to calculate what day of the week is 40 days from this moment.
Next: Write C# Sharp program to add a number of whole and fractional values to a date and time.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.