What's Here?
- Members: 149,068
- Replies: 505,578
- Topics: 79,635
- Snippets: 2,663
- Tutorials: 706
- Total Online: 1,293
- Members: 86
- Guests: 1,207
|
Inputs a number -> outputs a character
Inputs a character -> outputs a number
|
Submitted By: DeeViLiSh
|
|
Rating:

|
|
Views: 32,601 |
Language: C++
|
|
Last Modified: August 31, 2006 |
Snippet
#include <iostream.h>
#include <stdlib.h>
int main()
{
int number;
char letter;
int option;
cout<<"Convert ASCII numbers into characters and vice versa";
cout<<endl<<"[1] * ASCII -> ABC"
<<endl<<"[2] * ABC -> ASCII"
<<endl<<"[3] * EXIT"<<endl;;
cin>>option;
switch (option) //Detects the option
{
case 1:
cout<<"Enter a number : ";
cin >> number; //Inputs the number
cout<<"The number you entered is : \""<<char(number)<<"\" in ASCII"<<endl; //Ouputs the same number in char
break;
case 2:
cout<<"Enter a letter : ";
cin >> letter; //Inputs the letter
cout<<"The character you entered is : \""<<int(letter)<<"\" in ASCII"<<endl; //Outputs the same letter in int
break;
case 3:
return 0;
default: //If user chooses anything else besides options given
cout<<"Invalid Option!";
system("PAUSE");
break;
}
system("PAUSE");
return 0;
}
Copy & Paste
|
|
|
Be Social
Reference Sheets
Bye Bye Ads
Monthly Drawing
Top Contributors
Top 10 Kudos This Month
|