Here is a sample program that I wrote a very long time ago while I am teaching in one of the university in Bacolod City, Negros Occidental Philippines in my C++ class. This program will ask the user to give a series of years and then our program will check if the given year is a leap year or not using two dimensional array. I am using CodeBlocks as my text editor and Dev C++ as my C++ compiler in this sample program. I hope you will find my work useful. Thank you.
My mobile number here in the Philippines is 09173084360.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Program Listing
#include <iostream>
using namespace std;
main()
{
int years[2][2];
cout << "\n\n\t\t\t LEAP YEAR LISTER 1.O";
cout << "\n\t Created By: Mr. Jake Rodriguez Pomperada,MAED-IT";
cout << "\n\n";
for (int row=0; row <2; row++) {
for (int col=0; col <2; col++) {
cout << "Enter Year :=> ";
cin >> years[row][col];
}
}
cout << "\n\n";
// Leap Year
cout << "LIST OF LEAP YEAR";
cout << "\n\n";
for (int row=0; row <2; row++) {
for (int col=0; col <2; col++) {
if (years[row][col]%4==0)
{
cout << " " << years[row][col] << " ";
}
}
}
cout << "\n\n";
// not a leap year
cout << "LIST OF NOT A LEAP YEAR";
cout << "\n\n";
for (int row=0; row <2; row++) {
for (int col=0; col <2; col++) {
if (years[row][col]%4==0)
{
}
else {
cout << " " << years[row][col] << " ";
}
}
}
cout << "\n\n";
system("PAUSE");
}