/*Program for displaying ASCII Code of entered character until the user press '-'*/ /*Program for displaying ASCII Code of entered character until the user press 'n' or 'N'.*/ #include <iostream> #include <conio.h> using namespace std; int main() { char ch; do { cout << "\nEnter character?\t"; ch = _getche(); cout << "\nASCII Code of " << ch << " is\t" << static_cast<int>(ch); cout << "\nDo u want to run again ? (y/n)\t"; ch = _getche(); } while (ch != 110 && ch != 78); cout << endl; return 0; } /*Program for displaying character against entered ASCII Code until the user press '0'*/ #include <iostream> using namespace std; int main() { int ac; cout << "Enter code (1-255)?\t"; cin >> ac; do { cout << "Character against ASCII Code " << ac << " is\t" << static_cast<char>(ac) << "\n\n"; cout << "Enter code again or\nTo end program press '0'?" << "\n"; cin >> ac; } while (ac != 0); return 0; } /*Program for displaying all ASCII Codes and characters associated with each code*/ #include <iostream> using namespace std; int main() { int ac = 0; cout << "ASCII Codes:\n\n"; while (ac <= 255) { cout << ac << " = " << static_cast <char> (ac) << "\n"; //or printf ("%d = %c\t\t", ac, ac); ac++; } cout << endl; return 0; }
This blog is about coding in some commonly used "High Level Languages" like C, C++, Java etc. At first, I will post here basic programs written in C++ language only.
Thursday, November 20, 2014
C++ Programs relating to ASCII Codes
ASCII Codes and their Characters:
Labels:
C++ Programs
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment