Monday, December 10, 2007

How to declare a menu

How to declare a menu

To declare a menu

include

#include

int get_menu_choice( void );

main()

{

int decision;

decision = get_menu_choice();

cout<<"You chose Menu Option "<

return 0;

}

int get_menu_choice( void )

{ int choice1 = 0;

do

{ cout<<"\n" ;

cout<<"\n"<<" 1. Add a new record " ;

cout<<"\n"<<" 2. Change a record";

cout<<"\n"<<" 3. Delete a record";

cout<<"\n"<<" 4. Quit";

cout<<"\n" ;

cout<<"\nEnter a selection: " ;

scanf("%d", &choice1 );

} while ( choice1 <> 4 );

return choice1;

}

Result :

No comments: