Question:
What is wrong with my function in C?
Emily
2011-02-03 19:29:53 UTC
It isn't working, and I don't know why:
It gives me these:
read_sonde.c:67: error: expected declaration specifiers or ‘...’ before ‘U’
read_sonde.c:68: error: expected declaration specifiers or ‘...’ before ‘V’
read_sonde.c:71: error: expected ‘;’, ‘,’ or ‘)’ before ‘=’ token



int calc_winds
(
float wind_dir;
float wind_spd;
float winds[];
U==-1*wind_spd*sin((wind_dir*M_PI)/180);
V==-1*wind_spd*cos((wind_dir*M_PI)/180);


FILE *output = fopen("wind.txt", "w");
if (output)
{
fprintf(output, "%d,%d", U, V);
}
return(winds)
)
Four answers:
2011-02-03 21:21:27 UTC
this should be that-



int calc_winds

(

float wind_dir;

float wind_spd;

float winds[];

float U,V;

U=-1*wind_spd*sin((wind_dir*M_PI)/18…

V=-1*wind_spd*cos((wind_dir*M_PI)/18…





FILE *output = fopen("wind.txt", "w");

if (output)

{

fprintf(output, "%d,%d", U, V);

}

return(winds)

}





i have made three changes in it-

1. i have declared the variables U and V.

2. i have repaced == with =.

3. i have ended the function with closing curly brace ( ' } ' ) instead of parenthesis( ' ) ' ).



try it and tell us does it work?
JoelKatz
2011-02-04 03:34:01 UTC
I don't see where you declare U or V. What types are they supposed to be?



Are you sure you mean "==" there? Are you trying to test for equivalence?
k g
2011-02-04 03:38:19 UTC
well idk



but why is it U==-1 and V==-1



shouldnt it be U=-1 and V=-1



unless its a comparsion and the rest of your U and V isnt shown its just ......

whats fprintf?



can u look at my question



https://answersrip.com/question/index?qid=20110203193213AA4u0Bw



its a binary to decimal program thanks
tbshmkr
2011-02-04 03:36:58 UTC
Declare U && V

=

NOT U ==

NOT V ==

--

U = (-1 * .... );

V = (-1 * .....);

-


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...