Saturday, 28 March 2015

C++ program to print the ASCII characters

Q: How to print ASCII characters using two for loops in C++

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int ASCII;
    char ch;
    cout << "\t.....ASCII codes of Capital Letters....." << endl;
    for(ch='A';ch<='Z';ch++)
    {
      ASCII = static_cast<int>(ch);
      cout << "\t\t" << ch << setw(15) << setfill('.') << ASCII;
      cout << endl;                     
    }
    cout << "\n\t.....ASCII Codes of Small Letters....." << endl;
    for(ch='a';ch<='z';ch++)
    {
      ASCII = static_cast<int>(ch);
      cout << "\t\t" << ch << setw(15) << setfill('.') << ASCII;
      cout << endl;                                           
    }
system("pause");
return 0;   
}

0 comments:

Post a Comment