/* This program will add two floating point numbers and print the result */ #include main() { /* The following definitions declare that the variable will hold a real number */ float variable1; float variable2; float variable3; variable1 = 2.0; variable2 = 3.0; variable3 = variable1 + variable2; /* %f is a format identifier. When the compiler encounters the %f, it stops, goes to the first item after the comma, extracts the value of the variable3 and then prints it as a FLOAT (i.e.: a number with a decimal point. Then it returns to printing. */ printf("The sum is %f\n", variable3); } /* Try adding these lines: printf("the sum of %f and %f is %f\n", variable1, variabl2, variable3) */ /* For some real craziness, try adding these lines: printf("the sum of %d and %d is %d\n", variable1, variabl2, variable3) */