Q:

Printing all the ASCII Values in C/C++

Hello Everyone its been Long that I am not in touch with the C/C++ Language and was just revising the concepts again and I came across this question which asked to write a program to display all the ASCII characters and I wrote the following good, but it is not giving expected result.  Can anyone please tell what is the Problem with this code. 
#include<iostrem.h>
int main()
{
    unsigned char a;
    for(a = 0; a < 256; ++a)
    {
        cout << a << " ";
    }
    return 0;
} 

A:

a is always less than 256, since an unsigned char cannot possibly go higher than 255.  You've written an infinite loop. 
Your include also has a mispelling and extra .h and you didn't use the std namespace on cout. 
edit: Finally, technically, ASCII only counts the first 128 characters, everything beyond that is the domain of various extended character sets. 

A:

If you can use <stdio.h>, then it is easier. 
#include <stdio.h>

int main()
{
    for(int i = 0; i <= 255; i++) {
      fprintf(stdout, "[%d]: %c\n", i, i);
    }

  return 0;
}

A:

The other answers have this well covered.  I just thought I would throw in that it might be good to check if the characters are printable before printing them:
#include <cctype>
#include <iostream>

int main()
{
    for(int a = 0; a < 256; ++a) // use int (big enough for 256)
        if(std::isprint(a)) // check if printable
            std::cout << char(a) << " "; // print it as a char
}

