Medina, John Cedrick M. Bscs - S2: Output
Medina, John Cedrick M. Bscs - S2: Output
BSCS – S2
Output
Code
#include <iostream>
using namespace std;
int main()
{
//Medina, John Cedrick M.
//BSCS - S2
char ans1='y';
bool ans = true;
cout << "The code should output one of two possible messages, which are leap
year or common year.";
while(ans)
{
int year;
cout << "\n\nEnter The year: ";
cin >> year;
if(year % 400 == 0 && year % 4 == 0 )
{
cout << "("<< year << ") is a leap year!";
}
else if (year % 100 == 0)
{
cout << "("<< year << ") is a common year!";
}
else if (year < 1600)
{
cout << "("<< year << ") is a common year!";
}
else if (year % 4 == 0)
{
cout << "("<< year << ") is a leap year!";
}
cout << "\n\nWould you like to try again? y/n: ";
cin >> ans1;
if(ans1 == 'Y'|| ans1 =='y')
{
ans = true;
}
else
{
ans = false;
}
}
return 0;
} }
return 0;
}