Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9241031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:17:40+00:00 2026-06-18T08:17:40+00:00

Trying to write the wind chill factor equation in C++, and am having trouble

  • 0

Trying to write the wind chill factor equation in C++, and am having trouble with my equation and return value.

this is the function where the error comes up.

void eqfunction(int temperature, int windspeed){
    int windindex;
    windindex = 35.74 + (0.6215 * temperature);
    windindex = windindex - (35.75 * windspeed^0.16);
    windindex = windindex + ((0.4275 * temperature)*windspeed^0.16);
    return windindex;
}

Edit: (Ed.) after fixing the function following advice given in answers, new errors crop up:

float windChillFactor(float temperature, float windspeed){
    float windindex = 35.74f + 0.6215f * temperature;
    windindex -= 35.75f * std::pow(windspeed, 0.16f);
    windindex += 0.4275f * temperature * std::pow(windspeed, 0.16f);
    return windindex;
}

I know there are two things I’m doing wrong I just don’t know how to fix them. Obviously its the “^” and my return value. how would I create a square from 0.16 for windspeed?
And how would I create a correct windindex return value?

These are my errors

1>c:\users\ryan\desktop\final.cpp\final.cpp\final project.cpp(18):
  warning C4244: 'argument' : conversion from 'int' to 'float',
  possible loss of data
1>c:\users\ryan\desktop\final.cpp\final.cpp\final project.cpp(18):
  warning C4244: 'argument' : conversion from 'int' to 'float',
  possible loss of data
1>c:\users\ryan\desktop\final.cpp\final.cpp\final project.cpp(18):
  error C2440: '=' : cannot convert from 'void' to 'int'
1>          Expressions of type void cannot be converted to other types
1>c:\users\ryan\desktop\final.cpp\final.cpp\final project.cpp(22):
  error C2556: 'float eqfunction(float,float)' : overloaded function differs
  only by return type from 'void eqfunction(float,float)'
1>          c:\users\ryan\desktop\final.cpp\final.cpp\final project.cpp(6) :
            see declaration of 'eqfunction'
1>c:\users\ryan\desktop\final.cpp\final.cpp\final project.cpp(22):
  error C2371: 'eqfunction' : redefinition; different basic types
1>          c:\users\ryan\desktop\final.cpp\final.cpp\final project.cpp(6) :
            see declaration of 'eqfunction'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:17:41+00:00Added an answer on June 18, 2026 at 8:17 am

    While you haven’t included the error message(s) the compiler gives (which you should always do), here are the errors I see:


    void eqfunction(int temperature, int windspeed){
    
    • error: Your function returns a value. void functions are functions that don’t return anything, also known as “procedures” in some other programming languages. Because you want to return real numbers, you may want to use float (there are also double and long double, but in everyday use, float is often precise enough).
    • design error: Temperature and windspeed are real numbers, so your function should not take int but float
    • It is good practice to give your functions a descriptive name, like you have done with the variable names (unlike in C, in C++ it is more common to not use mnenomic functions names)

        int windindex;
    
    • It is good practice to always initialize builtin types
    • You are computing the final result using real types, but if you use int to store intermediate results, significant information might get lost (when assigning real types to integral types, the fractional part is discarded); so instead of int, use float

        windindex = 35.74 + (0.6215 * temperature);
        windindex = windindex - (35.75 * windspeed^0.16);
        windindex = windindex + ((0.4275 * temperature)*windspeed^0.16);
    
    • error: the operator ^ is the bitwise exclusive-or operator in C++. The power function is a library function in C++, namely std::pow(x,y) from the cmath header
    • the arithmetic operations a = a + something, a = a - something, a = a * something and a = a / something can be simplified to a += something, and likewise for the others
    • in C++, a literal in the form 1.0 indicates a double value, and a literal in the form 1.0f indicates a float value

        return windindex;
    }
    
    • that’s okay.

    So, taking those points into account, this might better suit what you want:

    #include <cmath>
    
    float windChillFactor(float temperature, float windspeed){
        float windindex = 35.74f + 0.6215f * temperature;
        windindex -= 35.75f * std::pow(windspeed, 0.16f);
        windindex += 0.4275f * temperature * std::pow(windspeed, 0.16f);
        return windindex;
    }
    

    Note that because of operator precedence, * and / are evaluated before + and -, so your parentheses weren’t needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've had problem when trying write a function which has a default value when
I am trying write a function that generates simulated data but if the simulated
Trying to write a function to see how often an object exists and give
Trying to write Unit test for Silverlight 4.0 using Moq 4.0.10531.7 public delegate void
Trying to write a matrix-multiplying function for arbitrary-sized matrices in C. I'm trying the
Trying to write function that numerize items of list and returns list of tuples
I referred to this article http://www.codeproject.com/KB/security/DotNetCrypto.aspx and I am trying write an encrypted string
Trying to write a procedure that given a value and a list, it deletes
I'm trying write a code that can the set property value through the lambda
I am trying write an application that receives lat/lng and return appropriate location. (i.e

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.