icp/oer/courses/c-basics/sections/17-preprocessor/03-libraries/program.c

26 lines
894 B
C
Raw Normal View History

2018-05-05 22:18:02 +00:00
#include <stdio.h>
#include <stdlib.h>
// You typicly write all of your includes in the beginning
// We want to use some math function.
// To do so we have to either write them our self or include a library.
// Because we are lazy and don't want to spend time debugging we will include the math.h library.
// TODO: Include math.h
// Be carefull! For some libraries you have to tell the linker which libraries he has to link to your program
// I.g in this case, because we are compiling with gcc, we need to set the -lm flag
int main(int argc, const char *argv[])
{
int Value = 90;
float SinValue = sin(Value);
float CosinValue = cos(Value);
printf("The sin of %d is %4.2f and the cosin is %4.2f.", Value, SinValue, CosinValue);
}
// On many linux-distributions you can use "man <function>" to get information
// If you are on linux, try using :
// man atof
// man printf
// man sin