5 Replies - 254 Views - Last Post: 05 February 2018 - 07:55 PM Rate Topic: -----

#1 XtremeNovice  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 05-February 18

temperature & Wind Chill

Posted 05 February 2018 - 01:58 PM

I literally started TRYING to code like last week. I am a student. Just bare with me please. And I'm not even sure what you mean by putting tags on the code but...
I'm trying to calculate this windchill given this formula, the code also converts celcius to farenheit. Eventually I'll have to put this in a loop when I figure out how to do it right.

Here are the errors. below is the code

[71] gcc -Wall lab4.c -lm
lab4.c: In function 'main':
lab4.c:28:52: error: invalid operands to binary ^ (have 'float' and 'double')
windchill = 35.74 + (0.6125 * T) - 35.75 * pow(V^0.16) + (0.4275 * T) * pow(V^0.16); //formula wont work. saying V & T first use
^
lab4.c:28:47: error: too few arguments to function 'pow'
windchill = 35.74 + (0.6125 * T) - 35.75 * pow(V^0.16) + (0.4275 * T) * pow(V^0.16); //formula wont work. saying V & T first use
^
lab4.c:28:81: error: invalid operands to binary ^ (have 'float' and 'double')
windchill = 35.74 + (0.6125 * T) - 35.75 * pow(V^0.16) + (0.4275 * T) * pow(V^0.16); //formula wont work. saying V & T first use
^
lab4.c:28:76: error: too few arguments to function 'pow'
windchill = 35.74 + (0.6125 * T) - 35.75 * pow(V^0.16) + (0.4275 * T) * pow(V^0.16); //formula wont work. saying V & T first use
^
lab4.c:12:8: warning: variable 'windchill' set but not used [-Wunused-but-set-variable]
float windchill;
^
:~/101/lab/lab4 [72]




#include <stdio.h>
#include <math.h>

int main (void) {

   float celsius;
   int farenheit;
   int wind;                        //does this need a seperate declaration?
   float windchill;
   float V, T;                 //does this need to be declared separately? does it need initialization

   fprintf(stdout, " What is the temperature (degrees farenheit)?\n");
   fscanf(stdin, "%i", &farenheit);

   celsius = (farenheit - 32.0) * 5.0 / 9.0;

   fprintf(stdout, "%6d degrees F = ", farenheit);
   fprintf(stdout, "%6.2f", celsius);
   fprintf(stdout, " degrees C \n\n ");


   fprintf(stdout, "Enter a value for wind in MPH\n");
   fscanf(stdin, "%6f", &V); //is this supposed to say wind or V?

   windchill = 35.74 + (0.6125 * T) - 35.75 * pow(V^0.16) + (0.4275 * T) * pow(V^0.16); //formula wont work. saying V & T first use
                                                                                       // also saying too few arguments, when arguments inserted. no effect

   fprintf(stdout, " The windchill for %6d farenheit at %6d mph winds is ___", farenheit, wind); // dashed line because I'm not 
                                                                                                 // sure what to put there yet 
   return 0;



Is This A Good Question/Topic? 0
  • +

Replies To: temperature & Wind Chill

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13763
  • View blog
  • Posts: 54,941
  • Joined: 12-June 08

Re: temperature & Wind Chill

Posted 05 February 2018 - 02:01 PM

Quote

lab4.c:28:76: error: too few arguments to function 'pow'


Look at the parameters for 'pow'. That doesn't match what you have.
http://www.cplusplus...ence/cmath/pow/
Was This Post Helpful? 0
  • +
  • -

#3 XtremeNovice  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 05-February 18

Re: temperature & Wind Chill

Posted 05 February 2018 - 02:07 PM

When I did that, it told me that the left hand side had no effect. It wasn't in a printf statement though.

This post has been edited by ndc85430: 05 February 2018 - 10:14 PM
Reason for edit:: Removed quote of previous post. Please just press "Reply" in future.

Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13763
  • View blog
  • Posts: 54,941
  • Joined: 12-June 08

Re: temperature & Wind Chill

Posted 05 February 2018 - 02:29 PM

pow(V^0.16)

This is only one parameter. Per the docs it needs two.

double pow (double base, double exponent);

Was This Post Helpful? 1
  • +
  • -

#5 XtremeNovice  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 05-February 18

Re: temperature & Wind Chill

Posted 05 February 2018 - 07:45 PM

I got it working now. thank you
Was This Post Helpful? 0
  • +
  • -

#6 tony jay  Icon User is offline

  • New D.I.C Head

Reputation: 18
  • View blog
  • Posts: 46
  • Joined: 31-January 18

Re: temperature & Wind Chill

Posted 05 February 2018 - 07:55 PM

Good man!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1