I have already made the majority of the program, what I am trying to achieve is removing the character scan from the main function and bring it out in order to call it. I dont know what type of fucntion it would be though(i.e. char continue())this is what I was thinking but it does not work. Any help would be great
#include <cstdio>
#include <cstdlib>
void isleap( int );
int getyear();
void main()
{
int y; // hold the year
//call the function
char ans='y';
char ans2='Y';
//set while loop
while(ans=='y'|| ans=='Y'){
y = getyear(); //assign function value
if (y <= 1582)//test year to get proper response
{
printf("Warning: %d is before the modern calender adoption in 1582, results may be \ninaccurate!\n\n",y);
printf("The Year Entered is %d\n", y);
}
else
{
printf("the year is %d\n", y);
}
isleap(y);// call is leap year function
printf("Would you like to continue? ");
scanf("%c",&ans);
scanf("%c",&ans);
}
system("pause");
}
int getyear()
{
int year; /// year local to the function
printf("Please Enter a Year:\n");
scanf("%d", &year);
return year;
}
void isleap( int x)
{
if(x % 400 == 0 || (x % 100 != 0 && x % 4 == 0)) //condition to test on year entered
{
printf("Year %d is a leap year\n\n", x);
}
else
{
printf("Year %d is not a leap year\n\n",x);
}
}