C examples for Operator:Arithmetic Operator
A pint is 2 cups, a cup is 8 ounces, an ounce is 2 tablespoons, and a tablespoon is 3 teaspoons.
#include <stdio.h> int main(void) { float PINTS_PER_CUP = .5; float OUNCES_PER_CUP = 8; float TBS_PER_CUP = 2 * OUNCES_PER_CUP; // tablespoons/ounce * ounces/cup float TSP_PER_CUP = 3 * TBS_PER_CUP; // teaspoons/tablespoon * tablespoons/ounce * ounces/cup float cups;/*from w w w . ja v a 2 s . co m*/ printf("Enter an amount in cups:"); scanf("%f", &cups); printf("%f cups is equivalent to:\n", cups); printf("%f pints\n", cups * PINTS_PER_CUP); printf("%f ounces\n", cups * OUNCES_PER_CUP); printf("%f tablespoons\n", cups * TBS_PER_CUP); printf("%f teaspoons\n", cups * TSP_PER_CUP); return 0; }