Hello Guys,
Well i have a problem, I coded a program to print the ascii table, then give the user a option to either convert character into ascii or ASCII to character.
Well the latter is not working, and the loop to print the ascii table is having the same trouble.
Well I did that loop earlier, but there i used the characters as it is, having to make the loop little Inefficient. Here i want it to be done in this way...
But Explicit conversion of int to char is causing the trouble....
Please help me out...
Here is the code..
#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
int a,choice;
char b, choice2;
cout<<"Would you like to print the ASCII Table first? (Y/N)"<<endl;
cin>>choice2;
if(choice2=='y'||choice2=='Y')
for(int i=0;i<=255;i++)
{ cout<<endl;
cout<<(char)i<<" = "<<i<<" ";
}
else
{ cout<<"1.Character to ASCII"<<endl;
cout<<"2.ASCII to Character"<<endl;
cin>>choice;
if(choice==1)
{
cout<<"Enter the Character"<<endl;
cin>>b;
a=(char)b;
cout<<"ASCII value is "<<a;
}
else if(choice==2)
{
cout<<"Enter the Value "<<endl;
cin>>a;
b=(int)b;
cout<<"The character is "<<b;
}
else
cout<<"Invalid Option"<<endl;
}
getch();
return 0;
}