Using multiple functions, cin and variable conflicts

Hi,

I'm having trouble creating multiple functions and using the cin command to input various values.When trying to run compile the code it states that some of the variables have not been declared in this scope. It also says that the expression list is treated as compound expression in initialiser (-fpermissive).

In the int main() function it also complains about the variables not being declared appropriately either.

Please could somebody help and tell me where I'm going wrong?

Thanks

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
  #include <iostream>

using namespace std;

// declaring variables



//declaring functions

float betaimpact (beta, secreturn)
{

betaimpact= beta*secreturn
return (betaimpact);

},

float barraimpact (bestbarraret,bestfactorload,worstbarraret,worstfactorload)
{

barraimpact= (bestbarraret*bestfactorload) - (worstret*worstbarrafactorload);
return (barraimpact);
}



float fap (exposure,betaimpact,barraimpact)

,{
fap= exposure * (betaimpact-barraimpact);
return (fap);

}



int main()
{

// generating the outputs to calculate factor adjusted profit

cout<< "Enter the security beta:" ;
cin >> beta;
cout << "Enter the security return:";
cin >> secreturn;
cout<< "Beta impact is "<<betaimpact;

cout << "Enter the Best factor loading:";
cin>> bestbestfactorload;
cout<< "Enter the Worst Barra loading:";
cin>> worstfactorload;

cout << "Enter the worst factor return";
cin>> worstbarraret;

cout<< "Enter the best factor return";
cin>> bestbarraret;

cout<<endl<<fap<< "Factor adjusted profit is"<< fap<< "dollars";

return (fap);

}






* you have a junk comma on line 17 and 30

* your function definition is not written correctly: float fap (exposure,betaimpact,barraimpact) does not specify the type of its arguments. If you want them to be float, then write: float fap (float exposure, float betaimpact, float barraimpact)

* you have not declared the variables you are using. You also are not using the right syntax to invoke functions. You don't need the parentheses after the return. You don't need to name your returning variables after the function they return from, although you may.
Last edited on
Topic archived. No new replies allowed.