
(Written in C++, and variables might be messed up a bit)
- Code: Select all
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int main()
{
int number;
char letter;
char word;
int x = 0;
int option;
int num;
int lag = 10;
string s;
int a;
int key;
while (lag>9)
{
cout<<"Convert ASCII numbers into characters and vice versa";
cout<<endl<<"[1] * ASCII -> ABC"
<<endl<<"[2] * ABC -> ASCII"
<<endl<<"[3] * EXIT"<<endl;;
cout<<"Option :";
cin>>option;
switch (option)
{
case 1:
cout<<"Enter a letter : ";
cin >> letter; //Inputs the number
cout<<"Enter the shift key: ";
cin >> key; //Gets the key
cout<<"The number you entered is : \""<<char(number) + key<<"\" in ASCII"<<endl; //Ouputs the same number in char
break;
case 2:
cout << "Please enter the letter";
cin >> word;
cout << "The ASCII for this word is:";
cout << int(word);
cout << " \n";
break;
case 3:
return 0;
default:
cout<<"Invalid Option!";
system("PAUSE");
break;
}
}
system("PAUSE");
return 0;
}