0% found this document useful (0 votes)
176 views

Convert ASCII To Character and Character To ASCII Code Using C++

An Example of static_cast of C++ to Converting Data types in c++

Uploaded by

Aamir Khan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
176 views

Convert ASCII To Character and Character To ASCII Code Using C++

An Example of static_cast of C++ to Converting Data types in c++

Uploaded by

Aamir Khan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Convert ASCII to Character and Character to ASCII Code using C++

Code 1 (ASCII to Characters)


//Ascii to Charecter by Aamir khan #include <iostream> using namespace std; int main() { int number; cout << "Enter an ASCII Code to see the character "; cin >> number; cout << "you enter " << number; //Convert data type to char cout <<" and the Charecter for " << number <<" is " << static_cast <char>(number) << endl; return 0;

Code 2 (Characters to ASCII)


// Charecter to ASCII by Aamir khan #include <iostream> using namespace std; int main() { char number; cout << "Enter a character to see the ASCII Code "; cin >> number; cout << "you enter " << number; //Convert data type to int cout <<" and the ASCII code for " << number <<" is " << static_cast <int>(number) << endl; return 0;

Acknowledgment: On the Above two Programs we use static_cast which is used to Converts expression to the type of type-id based solely on the types present in the expression. e.g static_cast <type-id> ( expression ) Follow = twitter.com/hacktw or Like = Facebook.com/hackbookk

You might also like