Friday, June 28, 2013

Ascii Table

//Ascii table in hexadecimal
//code and in decimal code

#include<iostream.h>
#include<conio.h>
void main () {
const int Nrows=32; // the number of horizontal rows
const int Ncol=3; // the number of vertical rows
int start=32; // the starting code( only the code from 32 to 256 is visible, from 0 to
// 31 is not visible to us.



for (int x=0; x<Nrows; x++){  //the for loop will start from 0 to 32 rows
int y=0;
for(y=0;y<Ncol; y++){ // the codes and the columns starts here
int code=start+x+y*Nrows;
cout<<dec<<code<<"\t"<<hex<<code<<"(hex)\t"<<(char) code<<"\t";
}
cout<<endl;
if ( x == Nrows/2){
cout<<" Press Any key to continue........";
getch();
}
}
}

// ^_^ have a nice day
P.S:
cout<<dec // the output value will be in decimal
cout<<hex // the output value will be in hexadecimal
if(x== Nrows/2){
cout<<"Press any key to continue...";
getch();
}
// waiting for a key to continue the table
// else the user cannot see all the characters and codes.

No comments:

Post a Comment