C++ Program to convert Hex to ASCII and vice-versa.


C++  Code  to Print Hex value of an ASCII charecter  and vice versa:
====================================================


#include <iostream>
using namespace std;
int main()

{int a;
    //cout<<"HEX -- ASCII CONVERTER \n\n* Enter 1 for Hex to ASCII \n* Enter 2 for ASCII to Hex \n* Or 0 to quit\n";
   do{
       cout<<"* Enter 1 for Hex to ASCII \n* Enter 2 for ASCII to Hex \n* Or 0 to quit\n";
cin>>a;
   if(a==1){
int z;
cout<<"Enter the hex code : ";
cin>>z;
char theX=z;
cout<<"The ASCII value for the  your hex is : "<<theX<<endl<<endl;
}
else if (a==2){

       char any;
       cout<<"Enter the  ASCII charecter : ";
       cin>>any;
       int any1=any;
       cout<<"The Hex value for the ASCII charecter you entered  is : "<<any1<<endl<<endl;
   }
}while(a!=0);
}
//created by Rainbow Matrix

No comments:

Post a Comment