what is wrong in this program

THE PROGRAM DOES NOT WORK
[code]
#include <iostream>
#include <string>
using namespace std;


double annualIncome();
void calculations(double annualIncome);


int main()
{
annualIncome();
calculations(double annualIncome); >>>>>>>> SOMETHING WRONG IN HERE?


return 0;
}
double annualIncome()
{
double annualIncome =0;
cout << "How much money do you wanna make a year?" << endl;
cin >> annualIncome;
return annualIncome;
}
void calculations(double annualIncome)
{
cout << annualIncome << endl;

}

What do you mean by "doesn't work"?
1. Fails to compile?
2. Crashes, while running?
3. Unexpected results?


Recheck the "how to call a function" from http://www.cplusplus.com/doc/tutorial/functions/

You do call one function correctly, but what do you do with its return value?
The other line is not a function call. It is a declaration.


PS. Fix the code tags in your post.

while it is legal to have the same name used all over, it is confusing to read.

you probably meant

double AI = annualincome();
calculations(AI);


where you have

annualIncome();
calculations(double annualIncome);

or possibly

calculations(annualincome());
Last edited on
Topic archived. No new replies allowed.