September 1998
Intermediate to advanced
848 pages
20h 13m
English
By now, you probably expect a sample program at the beginning of each chapter, and I won't disappoint you. Listing 4.1 presents a program that engages in a dialogue with the user.
/* talkback.c -- nosy, informative program */ #include <stdio.h> #include <string.h> /* for strlen() prototype */ #define DENSITY 62.4 /* human density in lbs per cu ft */ int main(void) { float weight, volume; int size, letters; char name[40]; /* name is an array of 40 chars */ printf("Hi! What's your first name?\n"); scanf("%s", name); printf("%s, what's your weight in pounds?\n", name); scanf("%f", &weight); size = sizeof name; letters = strlen(name); volume = weight / DENSITY; printf("Well, %s, your volume ... |
Read now
Unlock full access