Formula based program
Formula #1 (Leap year)
Enter a year: 2016
Year is a leap year
The program for the formula is written in C# programming language and will accept a number as input year. Based on the conditions it will check whether the year is a leap year or not.
Note: If you are new to C# and Console Application. Try to code First C# Program
Let’s find out a simple and easy way to code these formula.
class Formula1 //Leap year
static void Main(string args)
Console.Write("Enter a year: ");
int year = Convert.ToInt32(Console.ReadLine());
if (((year % 100 != 0) && (year % 4 == 0)) || (year % 400 == 0))
Console.WriteLine("Year is a leap year");
Console.WriteLine("Year is not a leap year");
The input year here is 2016. So, based on the conditions it will check whether the year is a leap year or not. The output is shown below:
For any query, comment us below.
Skip to Main Table – Formula based program
Next – Formula based program #2
Click imagination hunt to read latest blogs.
Keep learning and sharing...