u

Thursday 5 January 2012

C++ Program to print the corresponding ASCII character


C++ Program to print the  corresponding ASCII character
#include <stdio.h>
#include <fstream.h>
#include <stdlib.h>
#include<conio.h>
main()
    {
    clrscr();
    char line[512]; /* input string */
    char sym;       /* ASCII code number */
    cout<<"Please enter the number to be factored: ";
    cin.getline(line, 512);
    sym = atoi(line);
    cout<<int(sym)<<"  is the ASCII code for ";
    if (sym == 0)
    cout<<"null\n";
    else if (sym == ' ')
    cout<<"blank\n";
    else if (sym == 127)
    cout<<"del\n";
    else if (sym >=  1 && sym <=  31)
    cout<<"CONTROL-\n"<< sym + 64;
    else if (sym >= '0' && sym <=  '9')
    cout<<"digit \n"<< sym;
    else if (sym >= 'A' && sym <=  'Z')
    cout<<"UPPERCASE \n"<< sym;
    else if (sym >= 'a' && sym <= 'z')
    cout<<"lowercase \n"<< sym;
    else
    cout<<"punctuation mark \n"<< sym;
    getch();
    }

0 comments:

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More