Day 3 Lab / Lecture

/*
Day 3 lecture / lab work freezing
*/
/*–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––*/
/*  This program uses linear interpolation to                  */
/*  compute the freezing temperature of seawater.              */
#include <stdio.h>
#include <math.h>
int main(void)
{
/*  Declare variables.  */
double a, f_a, b, f_b, c, f_c;
/*  Get user input from the keyboard.  */
printf("Use ppt for salinity values. \n");
printf("Use degrees F for temperatures. \n");
printf("Enter first salinity and freezing temperature: \n");
scanf("%lf %lf",&a,&f_a);
printf("Enter second salinity and freezing temperature: \n");
scanf("%lf %lf",&c,&f_c);
printf("Enter new salinity: \n");
scanf("%lf",&b);
//  Use linear interpolation to compute   new freezing temperature.          
f_b = f_a + (b-a)/(c-a)*(f_c - f_a);
/*  Print new freezing temperature.  */
printf("New freezing temperature in degrees F: %4.1f \n",f_b);
return 0;  /*  Exit program.  */
}

Comments

Popular posts from this blog

Day 4 HW

Day 3 Mods and HW

10/17/2017 Motor w/ Potentiometer