C examples for Data Type:float
Have the program loop through pairs of input values until the user enters nonnumeric input.
#include <stdio.h> int main( void ) { //from www . jav a 2 s .c o m double n, m; double res; printf("Enter a pair of numbers: "); while (scanf("%lf %lf", &n, &m) == 2) { res = (n - m) / (n * m); printf("(%.3g - %.3g)/(%.3g*%.3g) = %.5g\n", n, m, n, m, res); printf("Enter next pair (non-numeric to quit): "); } return 0; }