Answer to Question 2.4

/* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
/* The C++ Answer Book */
/* Tony Hansen */
/* All rights reserved. */

//: print the sizes of all of the fundamental types
#include <stream.h>
 
void pr(char *type, unsigned int size)
{
     cout << "sizeof(" << type << ") = " <<
     size << "\n";
}

int main(int, char**)
{
    pr("char", sizeof(char));
    pr("short", sizeof(short));
    pr("int", sizeof(int));
    pr("long", sizeof(long));
    pr("unsigned char", sizeof(unsigned char));
    pr("unsigned short", sizeof(unsigned short));
    pr("unsigned int", sizeof(unsigned int));
    pr("unsigned long", sizeof(unsigned long));
    pr("float", sizeof(float));
    pr("double", sizeof(double));
    pr("void *", sizeof(void *));
    pr("char *", sizeof(char *));
    pr("short *", sizeof(short *));
    pr("int *", sizeof(int *));
    pr("long *", sizeof(long *));
    pr("unsigned char *", sizeof(unsigned char *));
    pr("unsigned short *", sizeof(unsigned short *));
    pr("unsigned int *", sizeof(unsigned int *));
    pr("unsigned long *", sizeof(unsigned long *));
    pr("float *", sizeof(float *));
    pr("double *", sizeof(double *));
    pr("int (*)()", sizeof(int (*)()));
    return 0;
}

Menu of Chapter 2 Answers 
Answer to Question 2.5