Q:

C# program to find out the leap years from 1900 to 1950

belongs to collection: C# Basic Programs | Looping programs

0

For example:

  • 1604 is a leap year.
  • 1605 is not a leap year.
  • 1600 is a leap year.
  • 1900 is not a leap year.
  •  

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Consider the program:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    
    class Program
    {
        static void Main(string[] args)
        {
            int i     = 0;

            for (i = 1900; i <= 1950; i++)
            {   
                if( 
                    ((i % 4==0) && (i % 100 !=0)) ||
                    ((i % 4==0) && (i % 100 ==0) && (i%400==0)) 
                  )
                {
                    Console.Write(i + " ");
                }
            }

            Console.WriteLine();
        }
    }
}

Output

1904 1908 1912 1916 1920 1924 1928 1932 1936 1940 1944 1948

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C# program to print Even and Odd numbers from 1 to... >>
<< C# program to find out the prime numbers among 2 t...