In: Computer Science
Please write variables and program plan(pseudocode) of this C++ programming code:
#include <iostream>
using namespace std;
void leapYear(int x);
int main()
{
int x;
cout << "Enter a year: ";
cin >> x;
leapYear (x);
return 0;
}
void leapYear(int x )
{
if (x % 400 == 0)
{
cout << "This is a leap Year";}
else if
((x % 4 == 0) && (x % 100 != 0))
{
cout << " this is a leapYear";}
else
{
cout << "This is not a leap
Year";
}
}
PESUDOCODE
declaring the leapyear(int x) function;
main function()
{
declare variable x;
x=reading input from the user;
calling function leapYear(x);
}
leap year(int x)
{
if(x is divisible by 400) then
{
then the entered year is leap
year
}
else if(x is divisible by 4 but not 100 then):
{
Then the enetered year is a leap
year
}
else
{
Entered year is not a leap
year;
}
}
Variables used:
we have used a variable x in the main() which is used to store the user entered year
then we pass that x to the leap year function
we have used anathor variable x in the leapYear(int x)
there we used to x variable to check wheter the entered year is leapyear or not