C++ program that converts ASCII value to character and vice versa.
Answers
Answered by
2
#include <iostream>
// functions
int char2ascii(char ch){
return (int) ch;
}
char ascii2char(int ascii){
return (char) ascii;
}
//main
int main(){
std::cout << char2ascii('A') << std::endl; // 65
std::cout << ascii2char(65) << std::endl; // 'A'
return 0;
}
I assume you only require the methods. If the input is from user, modify the program accordingly. The logic shall remain similar.
Similar questions