what is wrong in this program

I want the program to show how much a month I should get in order to get an entered amount of income!

The output is 0 in all cases, what is wrong! I just don't get it how to call functions and all of that!

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
 #include <iostream>
#include <string>
using namespace std;


double askAnnualIncome();
double howMuchAMonths(double income);


int main()
{
	askAnnualIncome();
	howMuchAMonths(double(income));
	

	return 0;
}
double askAnnualIncome()
{
	double annualIncome;
	cout << "How much money do you wanna make a year?" << endl;
	cin >> annualIncome;
	return annualIncome;
}
double howMuchAMonths(double income)
{
	double monthlyIncome;
	monthlyIncome = income / 12;
	cout << "in order to do that, you gotta make " << monthlyIncome << endl;
	return monthlyIncome;
}
Line 13: There's no income parameter inside your main, so your parameter for your howMuchAMonths() is incorrect. You have the function askAnnualIncome() which returns a value, so you can use that as your parameter.

double howMuchAMonths(double income) you can change it to a void, because it seems unnecessary for the function to return a double value since you're just outputting the results.
Thanks!
Topic archived. No new replies allowed.