I am trying to work out a program where it takes a user inputed year and outputs if that year is a leap year or not.
Right now from what I have when I put leap years into the program it reads the output, "It is not a leap year." And when you input a year that is not a leap year it will output nothing and just end the program.
What am I doing wrong?
Thanks for the help in advance, looking forward to working through this.
Code:#include <iostream> int year; int leap1; int leap2; int leap3; int main() { std::cout << "Enter a year and I will determine if it's a leap year: " ; std::cin >> year ; leap1 = year % 4 ; leap2 = year % 100 ; leap3 = year % 400 ; if ( leap1 == 0 ) if ( leap2 != 0 ) if ( leap3 == 0 ) { std::cout << "It is a leap year." << '\n' ; } else { std::cout << "It is not a leap year." << '\n'; } return (0); }



LinkBack URL
About LinkBacks




CornedBee