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

  • Home
  • SEARCH
  • 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 7191725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:47:26+00:00 2026-05-28T19:47:26+00:00

Okay so I made this program to help me out with my homework and

  • 0

Okay so I made this program to help me out with my homework and because I wanted to improve my C expertise. Everything compiles fine when I do “gcc file.c -lm”, but when I run it with a number at the command line as an argument, my program only returns 70.0000.

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


double temp(double hour){
    double t = (3.14/12)*hour;
    double c = cos((double)t);
    double temp = 13 * c + 57;
    return temp; 
}

int main ( int argc, char *argv[]){
    double temperature = temp((double)atol(argv[0]));

    printf("%f\n", temperature);
}
  • 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-28T19:47:28+00:00Added an answer on May 28, 2026 at 7:47 pm

    argv[0] is probably your program name. You want argv[1], I expect. Check out this tutorial for a quick and easy explanation.

    Besides that, is there a reason you’re using atol(3) and casting to double rather than just using atof(3) which returns a double directly?

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

Sidebar

Related Questions

Okay, this is pretty weird. I made an app that listens for changes inside
Okay, so I have this Silverlight client program. I'm not allowed to use the
Okay, so this far I made my app display an activity and can link
Okay the question title may not have made sense... mostly because I don't know
Okay so im working on this php image upload system but for some reason
Okay, so this probably sounds terribly nefarious, but I need such capabilities for my
Okay. I know this looks like the typical Why didn't he just Google it
Okay so this is sort of a double question so I'll split it into
Okay this is going to seem really dumb but bear with me please. A
I ran a demo bmp file format helper program DDDemo.exe to help me visualize

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.