How to transfer multiple value from function to function?

im in trouble right now. i really dont know how, can u check my coding?
i want to transfer tday1, tday2 and tday3 from function daysInMonth to function numberOfDays.

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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
void daysInMonth (int d, int m, int y, int& tday1, int& tday2, int& tday3)
{
	
	if (m==1)
	tday1=31; 
	
 	else if (m==2)
 	if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0)
 	{
	 	tday2=29;
 	}
 	else
 	{
	 	tday2=28;	
	}
	
	else if (m==3)
	tday1=31;
	
	else if (m==4)
	tday3=30;
	
	else if (m==5)
	tday1=31;
	
	else if (m==6)
	tday3=30;
	
	else if (m==7)
	tday1=31;
	
	else if (m==8)
	tday1=31;
	
	else if (m==9)
	tday3=30;
	
	else if (m==10)
	tday1=31;
	
	else if (m==11)
	tday3=30;
	
	else if (m==12)
	tday1=31;
	
	numberOfDays (d, m, tday1, tday2, tday3);
}


void numberOfDays (int d, int m, int t1, int t2, int t3)
{
	int total=0;
	
	if (m==1)
	total = d;
	
	if (m==2)
	total = d + t1;
	
	if(m==3)
	total = d + t1 + t2;
	
	if (m==4)
	total = d + t1 + t1 + t2; 
	
	if (m==5)
	total = d + t1 + t1 + t2 + t3;
	
	if (m==6)
	total = d + t1 + t1 + t2 + t3 + t1;
	
	if (m==7)
	total = d + t1 + t1 + t2 + t3 + t1 + t3;
	
	if (m==8)
	total = d + t1 + t1 + t2 + t3 + t1 + t3 + t1;
	
	if (m==9)
	total = d + t1 + t1 + t2 + t3 + t1 + t3 + t1 + t1;
	
	if (m==10)
	total = d + t1 + t1 + t2 + t3 + t1 + t3 + t1 + t1 + t3;
	
	if (m==11)
	total = d + t1 + t1 + t2 + t3 + t1 + t3 + t1 + t1 + t3 + t1;
	
	if (m==12)
	total = d + t1 + t1 + t2 + t3 + t1 + t3 + t1 + t1 + t3 + t1 + t3;
	
	
	cout<<"the total days "<<total<<endl;

}

Last edited on
closed account (SECMoG1T)
Pass em ad parameters just as you did in your first function
Topic archived. No new replies allowed.