YouTip LogoYouTip

Cpp Examples Leap Year

# C++ Example - Check Leap Year [![Image 3: C++ Example](#) C++ Example](#) The user inputs a year, and the program determines whether that year is a leap year. ## Example #includeusing namespace std; int main(){int year; cout<>year; if(year % 4 == 0){if(year % 100 == 0){// // Here, if it is divisible by 400, it is a leap year if(year % 400 == 0)cout<<year<<" is a leap year"; else cout<<year<<" Nois a leap year"; }else cout<<year<<" is a leap year"; }else cout<<year<<" Nois a leap year"; return 0; } The output of the above program execution is: input year: 19901990 Nois a leap year [![Image 4: C++ Example](#) C++ Example](#) AI is thinking... [](#)[C++ Useful Resources](#) [C++ Quiz](#)[](#)
← Cpp Examples Prime NumberCpp Examples Quadratic Roots β†’