#include /* Fig. 7.28 (adapted) */ void function1( int a ); /* prototypes */ void function2( int b ); void function3( int c ); int choice; /* variable to hold user's choice */ int getChoice() { printf( "Enter a number between 0 and 2; 3 to end: " ); scanf( "%d", &choice ); return choice >= 0 && choice < 3; } int main() { /*@{}@XPCR{initialize array of 3 pointers to functions that each take an @CP {int} argument and return @CP {void}} */ void (*f[ 3 ])( int ) = { function1, function2, function3 }; while ( getChoice() ) /*@{}@XPCR{invoke function @CP {f[choice]} and pass @CP {choice} as an argument} */ (*f[ choice ])( choice ); printf( "Program execution completed.\n" ); return 0; } void function1( int a ) { printf( "You entered %d and function1 was called\n\n", a ); } void function2( int b ) { printf( "You entered %d and function2 was called\n\n", b ); } void function3( int c ) { printf( "You entered %d and function3 was called\n\n", c ); }