A Sample Program
Once again, you begin with a sample program. As before, you'll find some unfamiliar wrinkles that we'll soon iron out for you. The program's general intent should be clear, so try compiling and running the source code shown in Listing 3.1. To save time, you can omit typing the comments.
Listing 3.1. The rhodium.c Program
/* rhodium.c -- your weight in rhodium */ #include <stdio.h> int main(void) { float weight; /* user weight */ float value; /* rhodium equivalent */ printf("Are you worth your weight in rhodium?\n"); printf("Let's check it out.\n"); printf("Please enter your weight in pounds: "); /* get input from the user */ scanf("%f", &weight); /* assume platinum is $2000 per ounce */ /* 14.5833 converts pounds avd. to ounces ... |
Get C Primer Plus, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.