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 7659157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:17:45+00:00 2026-05-31T13:17:45+00:00

I’ve been Googling this for hours, but with no luck. I’m using standard c,

  • 0

I’ve been Googling this for hours, but with no luck.

I’m using standard c, calling a very simple method, and returning the correct value, but after the return the value is completely wrong.

call:

     //declare the gross and ficaTax variables
    double gross;
    double ficaTax;

    //calculate the gross and the ficaTax
    gross = calcGross(payRate, hours); printf("%f\n", gross); //DELETE

Method:

double calcGross(double rate, double hours){

    double gross;

    //if the person didn't work more than 40 hours  
    if(hours <= 40.0){
            gross = hours * rate;
    }

    //if the person did work more than 40 hours
    else{
            gross = 40.0 * rate + ((hours - 40.0) * rate * 1.5);
    }

    printf("%f \t", gross);
    return gross;
}

I’m printing out the values in and out of the method to try and solve it, but I can’t figure it out. Here is the output:

(correct) (incorrect, after return)

529.600000 , -858993459.000000

1371.522500 , 171798692.000000

100.000000 , 0.000000

1515.710000 , 171798692.000000

977.255000 , 1030792150.000000

5631.360000 , 687194767.000000

7502.400000 , 1717986918.000000

4335.106000 , 584115553.000000

1924.181500 , -618475291.000000

683.084000 , 137438953.000000

1348.424000 , 755914245.000000

1369.200000 , -858993460.000000

529.600000 , -858993459.000000

4441.522500 , -1030792152.000000

100.000000 , 0.000000

1882.710000 , 171798692.000000

My only guesses were either that my double post-return was too long to fit in the length of a double, but I stored it in a double pre-return and it printed correctly. If this is the case I couldn’t figure out how to fix it.
My other guess was that I’m printing it out wrong post-return, but I am printing it the same way.

I’m using Linux and with the gcc compiler if that matters. Any help would be appreciated. I have been trying to fix this seemingly simple problem for hours.

  • 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-05-31T13:17:45+00:00Added an answer on May 31, 2026 at 1:17 pm

    The problem is that you haven’t given a declaration or prototype for the calcgross() function before it’s being called in your first example.

    Without having seen a declaration/prototype for the function the C compiler will assume that it’s returning an int, not double, so things go terribly wrong.

    Place the following line somewhere before you call the function (ideally in a header that you include):

    double calcGross(double rate, double hours);
    

    Using the -Wall compiler option would give you the following warning about this:

    test.c:73:5: warning: implicit declaration of function 'calcGross' [-Wimplicit-function-declaration]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

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.