What is "Expected primary expression before..."?

The following is what i have typed up. i am not finished but basically i am trying to enter a temp in celsius and get an estimated windchill index. but when i try running what i have so far it says in int main() on the line that says chillWind = computeWC(float), it is saying expected prumarry expression before float. i am not sure what it means though.

#include <iostream>
#include <cmath>
using namespace std;

//prototypes
void intro();
float getTemp();
float computeWC(float);
void showWC(float,float);

int main ()
{
float celsius;
float chillWind;

intro();
celsius = getTemp();
chillWind = computeWC(float);
return 0;
}
void intro()
{
cout << "\tCalculate the wind chill for any given temperature\n\n";
return;
}
float getTemp()
{
int cNum;
while (cNum > 10)
{ cout << "Enter a temperature in Celsius that is less than 10: ";
cin >> cNum;
}
return cNum;
}
float computeWC(float cNum)
{
float windChill;

windChill = 13.12 + (.6215 * cNum);
return float (windChill);
}
float is the type of the variable, not its name.

Replace chillWind = computeWC(float) with chillWind = computeWC(celsius)
thank you for that. it makes so much more sense. I have now fiddle for well over 2 hours and believe I have done what I think is right. I am not sure however about 'v' in the equation.
this is the prompt I was give...
In cold weather, meteorologist report an index called the windchill factor, which takes into account the wind speed and the temperature. The index provides a measure of the chilling effect of wind at a given air temperature.

Windchill may be approximated by the formula:
w = 13.12 + (0.6215 * t) - (11.37 * v0.16) + (0.3965 * t * v0.016)
where v = wind speed in m/sec, t = temperature in degrees Celsius for t <= 10, w = windchill index (in degrees Celsius).

Write a program that computes the windchill index for a given temperature, input by the user. Your code should ensure that the restriction on the temperature is not violated. Functions should be:

void intro( ); // introduction to what the program does

float getTemp( ); // prompts the user to enter a temperature in Celsius
// Within this function, there should be data validation to make
// sure the value input is <= 10. If it isn't, there should be a
// loop that runs until the user inputs a valid number.

float computeWC(float); // computes the windchill index for the temperature input

void showWC(float, float); // shows the original temperature and the windchill index
Be sure you used functions in the <cmath> library, where appropriate.

then here is what I have types...

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

//prototypes
void intro();
float getTemp();
float computeWC(float);
void showWC(float,float);

int main ()
{
    float celsius;
    float chillWind;

    intro();
    celsius = getTemp();
    chillWind = computeWC(celsius);
    showWC(celsius,chillWind);
    return 0;
}
void intro()
{
    cout << "\tCalculate the wind chill for any given temperature\n\n";
    return;
}
float getTemp()
{
    int cNum;
    do
    { cout << "Enter a temperature in Celsius that is less than 10:  ";
    cin >> cNum;
   }
    while (cNum >= 11);

    return cNum;
}
float computeWC(float cNum)
{
    float windChill;
    float v;


    windChill = 13.12 + (.6215 * cNum) - (11.37 * pow(v,0.16)) + (.3965 * cNum * pow(v,.016));
    return windChill;
}
void showWC (float cNum,float windChill)
{
    cout << endl << cNum << " degrees Celsius" << endl << endl;
    cout << "The wind chill index is " << windChill << endl;
    return;
}
Last edited on
in your formula, v is supposed to be the wind speed but where in your code do you assign a value to it?
Last edited on
by the way, when you paste your code, highlight it and press the <> symbol on the right of the screen, it will format it nicely. Alternatively you can type
[code]
at the beginning and
[/code]
at the end.
Last edited on
yea i am not sure if i am supposed to assign something to it? i think i should email the instructor about that.
Imagine a real-world situation, how would you design the program? That's probably the expected solution!
Topic archived. No new replies allowed.