C++ Program To Print ASCII value of Digits,Uppercase and Lowercase Alphabates

#include<conio.h>
#include<iostream.h>
#include<dos.h>
#include<process.h>

void main()
{
clrscr();
char ch,a[]={“Made By : Neeraj Mishra”};
int j=0;

cout<<“Uppercase Alphabatesnn”;
for(int i=65;i<91;++i)
{
j++;
ch=i;
cout<<ch<<“:”<<i<<“t”;
if(j==10)
{
cout<<“n”;
j=0;
}
}
j=0;

cout<<“nnnLowercase Alphabatesnn”;
for(i=97;i<123;++i)
{
j++;
ch=i;
cout<<ch<<“:”<<i<<“t”;
if(j==10)
{
cout<<“n”;
j=0;
}
}

cout<<“nnnDigitsnn”;
for(i=48;i<58;i++)
{
ch=i;
cout<<ch<<“:”<<i<<“t”;
}

cout<<“nnnntt”;
for(i=0;a[i]!=’’;++i)
{
cout<<a[i];
sleep(1);
}
exit(0);
}

10 thoughts on “C++ Program To Print ASCII value of Digits,Uppercase and Lowercase Alphabates”

  1. Moremm L.A. Wozniak

    This is the first time i visited your site and one of your codes. Please help other newbie programmers love more and continue their passion by giving them a more simple and understandable code. I bet your trying to make it hard to read so that they won't just be able to simply copy/paste your code but for me, it would be better if its shorter and more simple. Since all you want to output is printing the ASCII value of digits, upper and lower case of alphabetical letters. Here's my code:

    #include

    using namespace std;
    int main(){
    cout<<"Printing UPPER-cased letters: "<(capInit)<<" : "<(lowInit)<<" : "<(digitInit)<<" : "<<digitInit<<endl;
    }
    }

    1. I agree with your code, i have written the program in old compiler i.e. turbo c++ and your program is for modern compiler like g++. Thanks for your valuable comment.

  2. sir.. i want to ask you that what is the use of sleep(i) and header files dos, process. please tell me about these things.
    One more question i want to ask you that can you please give me a program in which if i enter number then it gives me its spelling. for eg. 20 = twenty and 25 = twenty five

  3. this is ancient style and very misleading to new programmers. ISO C++ says you need to include iostream, not iostream.h, which is older than I am. chars are just integral types, there's no need for the numbers themselves, it's just more ambiguity. if you really want the value as a digit, you can use a static_cast to an int, or interpolate

    #include <iostream>

    int main() {
      for (char c = 'a'; c <= 'z'; ++c) {
       std::cout << static_cast<int>(c) << ": " << c << 'n';
      }
    }

    alternatively:

    #include <cstdio>

    int main() {
      for (char c = 'a'; c <= 'z'; ++c) {
       std::printf("%d: %cn", c, c);
      }
    }

    and please please please use int main() not void main().

    your final loop is also unnecessary, there is an overload for operator<<(std::ostream&, const char *); so you can just pass the cstring itself, rather than the individual characters.

    Another tip: people don't like it when you clear their screens when they weren't expecting it. These examples could easily be written to work on windows, mac, linux, and bsd if not for things like that (and the numerous other standards violations)

    1. Thanks for your valueable information. Actually this program was written three years ago, at that time I was in learning stage and was not much aware. Now I don't use such things.

Leave a Comment

Your email address will not be published. Required fields are marked *