Find the first day of a given year from a base year having first day as Monday | C # program to implement the above approach ; Function to find the day of 1 st January of Y year ; Count years between years Y and B ; Count leap years ; Non leap years ; Total number of days in the years lying between the years Y and B ; Actual day ; Driver code
using System ; class GFG { static void findDay ( int Y , int B ) { int lyear , rest , totaldays , day ; Y = ( Y - 1 ) - B ; lyear = Y / 4 ; rest = Y - lyear ; totaldays = ( rest * 365 ) + ( lyear * 366 ) + 1 ; day = ( totaldays % 7 ) ; if ( day == 0 ) Console . WriteLine ( " Monday " ) ; else if ( day == 1 ) Console . WriteLine ( " Tuesday " ) ; else if ( day == 2 ) Console . WriteLine ( " Wednesday " ) ; else if ( day == 3 ) Console . WriteLine ( " Thursday " ) ; else if ( day == 4 ) Console . WriteLine ( " Friday " ) ; else if ( day == 5 ) Console . WriteLine ( " Saturday " ) ; else if ( day == 6 ) Console . WriteLine ( " Sunday " ) ; else Console . WriteLine ( " INPUT ▁ YEAR ▁ IS ▁ WRONG ! " ) ; } static void Main ( ) { int Y = 2020 , B = 1900 ; findDay ( Y , B ) ; } }