Sunday, March 17, 2013

Using Ctype.h header

#include<iostream>
#include<ctype.h>
using namespace std;
int main()
{
    char ch;
    start:
    cout<<"Enter a character:";
    cin>>ch;
    if(isalnum(ch))
    {
        if (isdigit(ch))
        cout<<ch;
        else if(isupper(ch))
        {
            ch=(tolower(ch));
            cout<<ch;
        }
        else if(islower(ch))
        {
            ch=(toupper(ch));
            cout<<ch;
        }
    }
    else
    cout<<"It is aspecial character!!!";
    cout<<"\n\n"<<"Do you want to continue?(Press Y/N):";
    cin>>ch;
    if(ch=='Y' || ch=='y')
    goto start;
    return 0;
}

0 comments:

Post a Comment