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 :
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.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/csharp-exercises/datetime/csharp-datetime-exercise-10.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics