twitter

Maybe you all already know about ascii code. ascii code is the code that contains the number of binary digits that are within each letter. So each letter has a value or number of digits varies. Here's the program code more :



#include <iostream.h>
#include <stdlib.h>


int main()
{
        int number;
        char letter;
        int option;






        cout<<"Convert ASCII numbers into characters and vice versa";
        cout<<endl<<"[1] * ASCII -> ABC"
                <<endl<<"[2] * ABC -> ASCII"
                <<endl<<"[3] * EXIT"<<endl;;


        cin>>option;
        switch (option) //Detects the option
               {
                case 1:
                        cout<<"Enter a number : ";
                        cin >> number; //Inputs the number
                        cout<<"The number you entered is : \""<<char(number)<<"\" in ASCII"<<endl; //Ouputs the same number in char
                        break;


                case 2:
                        cout<<"Enter a letter : ";
                        cin >> letter; //Inputs the letter
                        cout<<"The character you entered is : \""<<int(letter)<<"\" in ASCII"<<endl; //Outputs the same letter in int
                        break;


                case 3:
                        return 0;


                default: //If user chooses anything else besides options given
                        cout<<"Invalid Option!";
                        system("PAUSE");
                        break;
                }


        system("PAUSE");
        return 0;
}


Running Result :











Jumat, 08 Juli 2011 | 0 komentar | Label: