C++ gurus and learners, we program ourselves :P all work is CC licensed

Friday, November 15

Program that converts ASCII number to character and vice versa By Umair Sajid

12:14 By

This Program can also be done using if-else structure but switch statement is most appropriate. 


#include<iostream>  /* Header Files */
#include<stdlib.h>    
#include<conio.h>    
using namespace std; 
int main() 
  int number,option; 
  char letter; 
 cout<<"1.Convert ASCII Value to Character "<<endl;
 
 cout<<"2.Convert Character to ASCII Value "<<endl;
 
 cout<<"Enter Your Choice :"; cin>>option;
 
 switch(option) 
 { 
 case 1:
   cout<<"Enter The Number :"; 
   cin>>number; 

   cout<<"The Corresponding character is :"<<char(number)<<endl;  break;
 
 case 2: 
   cout<<"Enter The Letter :";
   cin>>letter; 

   cout<<"ASCII Value of the letter is:"<<int(letter)<<endl; 
 break;
 
 default:
 cout<<"*** INVALID OPTION ***"; 
 break; 
 } 
 getch();
 }





6 comments :