Search & Find out

Sunday, December 6, 2009

CHARacter in switch case


#include "iostream.h"
#include "conio.h"
class yr
{
    private:
        char c;
    public:
        void accept ()
        {
            cout << "Enter a Character for gender:  ";
            cin  >> c;
        }
        void cal ();
};
void yr :: cal ()
{
    switch (c)
    {
        case 'm':
        case 'M':
            cout << "Male";
            break;
        case 'f':
        case 'F':
            cout << "Female";
            break;

        default:
            cout << "Invalid Gender Character\n";
    }
}
void main ()
{
    clrscr ();
    yr Y;
    Y.accept ();
    Y.cal ();
getch ();
}



Get the executable ( .exe ) file for this program..
Download

0 comments:

Post a Comment

 

My Blog List

Term of Use