Ok, so I made this program to help me with my homework, and because I wanted to improve my experience in C. Everything compiles fine when I do "gcc file.c -lm", but when I run it with the number on the command line as an argument, my program returns only 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); }
source share