Saturday 2 December 2017

C# Program to Convert a Given Number of Days in terms of Years, Weeks & Days


Code:

using System;
class program
{
    public static void Main()
    {
        int ndays, year, week, days, DAYSINWEEK=7;
        Console.WriteLine("Enter the number of days");
        ndays = int.Parse(Console.ReadLine());
        year = ndays / 365;
        week = (ndays % 365) / DAYSINWEEK;
        days = (ndays % 365) % DAYSINWEEK;
        Console.WriteLine("{0} is equivalent to {1}years, {2}weeks and {3}days", ndays, year, week, days);
        Console.ReadLine();
    }
}


Output:

Enter the number of days
1000
1000 is equivalent to 2 years, 38 weeks and 4 days


More C# Programs:





















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...