Skip to content

Instantly share code, notes, and snippets.

@shelling
Created October 7, 2009 11:11
Show Gist options
  • Select an option

  • Save shelling/203972 to your computer and use it in GitHub Desktop.

Select an option

Save shelling/203972 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <tgmath.h>
// Fortunately, all three functions required in this assignment
// is one-liner...XD
static inline double speed_at_temperature( int temperature );
static inline void instructions( void );
static inline double TRUNC( double digits );
int main( void ) {
double given_temp;
instructions();
scanf( "%lf", &given_temp );
printf( "Speed is %.2f", TRUNC( speed_at_temperature( given_temp ) ) );
return 0;
}
static inline double speed_at_temperature( int temperature ) {
return 1086.L * sqrt( ( 5.L * temperature + 297.L ) / 247.L );
}
static inline void instructions( void ) {
printf( "please give a number as temperature: " );
}
static inline double TRUNC( double digits ) {
return trunc( 100 * digits ) / 100.L;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment