Program to implement ASCII lookup table | C ++ implementation of ASCII lookup table ; Function to convert decimal value to equivalent octal value ; Function to convert decimal value to equivalent hexadecimal value ; Function to convert decimal value to equivalent HTML value ; ASCII lookup table ; Implicit typecasting converts the character into it 's equivalent ASCII ; Driver function
#include <iostream> NEW_LINE #include <string> NEW_LINE using namespace std ; int Octal ( int decimal ) { int octal = 0 ; string temp = " " ; while ( decimal > 0 ) { int remainder = decimal % 8 ; temp = to_string ( remainder ) + temp ; decimal /= 8 ; } for ( int i = 0 ; i < temp . length ( ) ; i ++ ) octal = ( octal * 10 ) + ( temp [ i ] - '0' ) ; return octal ; } string Hexadecimal ( int decimal ) { string hex = " " ; while ( decimal > 0 ) { int remainder = decimal % 16 ; if ( remainder >= 0 && remainder <= 9 ) hex = to_string ( remainder ) + hex ; else hex = ( char ) ( ' A ' + remainder % 10 ) + hex ; decimal /= 16 ; } return hex ; } string HTML ( int decimal ) { string html = to_string ( decimal ) ; html = " & # " + html + " ; " ; return html ; } void ASCIIlookuptable ( char ch ) { int decimal = ch ; cout << " Octal ▁ value : ▁ " << Octal ( decimal ) << endl ; cout << " Decimal ▁ value : ▁ " << decimal << endl ; cout << " Hexadecimal ▁ value : ▁ " << Hexadecimal ( decimal ) << endl ; cout << " HTML ▁ value : ▁ " << HTML ( decimal ) ; } int main ( ) { char ch = ' @ ' ; ASCIIlookuptable ( ch ) ; return 0 ; }