What's Here?
- Members: 137,226
- Replies: 481,492
- Topics: 75,061
- Snippets: 2,567
- Tutorials: 675
- Total Online: 2,063
- Members: 102
- Guests: 1,961
|
Inputs a number -> outputs a character
Inputs a character -> outputs a number
|
Submitted By: DeeViLiSh
|
|
Rating:
 
|
|
Views: 31,106 |
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
|
|
|
Reference Sheets
Bye Bye Ads
Monthly Drawing
Top Contributors
Top 10 Kudos This Month
|