Call a user function inside of a user function?

Hi,

I did some searching on the forums, but was unable to find an answer.

Is there a way to call a user defined function inside of a user defined funtion? For example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>

using namespace std;

int GetYear (void);
int GetMonth (void);
bool LeapYear (int);
int NumberOfDaysInMonth (int, bool);
int StartDay (int, int);
void PrintMonthCalendar (int, int, int, int);

int main ()
{	int Year;
	int Month;
	bool LeapYear;
	int NumberOfDaysInMonth;
	int StartDay;

	Year = GetYear();

	Month = GetMonth();

	LeapYear = LeapYear(Year);

	NumberOfDaysInMonth = NumberOfDaysInMonth(Month, LeapYear);

	StartDay = StartDay(Year, Month);	

	PrintMonthCalendar(Year, Month, NumberOfDaysInMonth, StartDay);

	return 0;
}

bool LeapYear (int Year)
{	bool LeapYear;

	if ( Year % 100 == 0 && Year % 400 != 0 )
	{	LeapYear = false;
	}
	else if ( Year % 4 == 0 )
	{	LeapYear = true;
	}
	else
	{	LeapYear = false;
	}

	return LeapYear;
}

int StartDay (int Year, int Month);
{	int StartDay;
	
	int DaysInYears = 0;
		
	for (int i = 1899; i < Year; i++)
	{	if ( LeapYear(i) )
		{	DaysInYears += 366;
		}
		else
		{	DaysInYears += 365;
		}
	}
	
	StartDay = DaysInYears % 7;
	
	return StartDay;
}


Obviously I omitted several other user defined funtions. I do not have a complier at the moment, so I'm not sure if this code works as is.

What I am not sure of is found in line 56 of the code. But I was wondering if this is a viable thing to do?

Thank you in advance.
That's fine.

In fact that's exactly what functions are for.
Thank you! I wasn't sure.
Topic archived. No new replies allowed.