×

C# Tutorial

Basics of .Net

C# Basics

C# Fundamentals

C# Operators

C# Loops

C# Type Conversions

C# Exception Handling

C# String Class

C# Arrays

C# List

C# Stack

C# Queue

C# Collections

C# Character Class

C# Class and Object

C# Namespaces

C# Delegates

C# Constructors

C# Inheritance

C# Operator Overloading

C# Structures

C# File Handling

C# Convert.ToInt32()

C# Int32 (int) Struct

C# DateTime Class

C# Uri Class

C# Database Connectivity

C# Windows

C# Other Topics

C# Q & A

C# Programs

C# Find O/P

C# - Leap Years From 1900 To 1950

Learn: How to check whether a year a Leap year or not. In this program, we are going to implement a program that will print Leap years from 1900 to 1950.
[Last updated : March 19, 2023]

To understand the program of leap year, first we should understand the concept of leap year.

What is Leap Year?

A year which follow below conditions is known as leap year:

  1. A year, which is divisible by 4 but not divisible by 100, is known as leap year.
  2. A year, which is divisible by 4, 100 and 400, is known as leap year.
  3. A year, which is divisible by 4, 100 but not divisible by 400 is not a leap year.

For example:

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

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

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

C# Basic Programs »

Advertisement
Advertisement

Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.