Printing ASCII keys...

Hi,

I am facing a problem that I don't know how to print ASCII keys decimal & binary values in C++, can u help?

Thanks,

Usama.

Comments

  • Hi Usama!
    /* After this program you can find your answer for all decimal and binary values*/
    char c;
    c='A';
    printf("Value %d",c);

    try it!
  • : Hi Usama!
    : /* After this program you can find your answer for all decimal and binary values*/
    : char c;
    : c='A';
    : printf("Value %d",c);
    :
    : try it!
    :
    Dear necipakif,
    Thanks for your help, but I am using Turbo C++ 3.0 compiler so please write code according to that as I the code which you have written does not work correctlt in Turbo C++.

    Thanks,
    Usama.
  • : : Hi Usama!
    : : /* After this program you can find your answer for all decimal and binary values*/
    : : char c;
    : : c='A';
    : : printf("Value %d",c);
    : :
    : : try it!
    : :
    : Dear necipakif,
    : Thanks for your help, but I am using Turbo C++ 3.0 compiler so please write code according to that as I the code which you have written does not work correctlt in Turbo C++.
    :
    : Thanks,
    : Usama.
    [purple]
    this shud work under turbo c++:[code]
    #include
    #include

    int main()
    {
    char c = 'A';
    clrscr();
    printf("%d", c);
    getch();
    return 0;
    }
    [/code]
    turbo c++ is veeeeery old and outdated compiler. better if u can avoid using it.
    [/purple]
    [hr][purple]~Donotalo()[/purple]

  • : : Hi Usama!
    : : /* After this program you can find your answer for all decimal and binary values*/
    : : char c;
    : : c='A';
    : : printf("Value %d",c);
    : :
    : : try it!
    : :
    : Dear necipakif,
    : Thanks for your help, but I am using Turbo C++ 3.0 compiler so please write code according to that as I the code which you have written does not work correctlt in Turbo C++.
    :
    : Thanks,
    : Usama.
    :

    [blue]
    printf does work in Turbo C++ 3.0, but it is a C function.
    If you want C++, try this.
    [code]
    #include "iostream.h"

    int main(int argc, char* argv[])
    {
    char ch = 'H';
    cout << ch << " dec Value=" << dec << (int)ch << endl;
    cout << ch << " oct Value=" << oct << (int)ch << endl;
    cout << ch << " hex Value=" << hex << (int)ch << endl;
    return 0;
    }
    [/code]
    [/blue]

  • : : : Hi Usama!
    : : : /* After this program you can find your answer for all decimal and binary values*/
    : : : char c;
    : : : c='A';
    : : : printf("Value %d",c);
    : : :
    : : : try it!
    : : :
    : : Dear necipakif,
    : : Thanks for your help, but I am using Turbo C++ 3.0 compiler so please write code according to that as I the code which you have written does not work correctlt in Turbo C++.
    : :
    : : Thanks,
    : : Usama.
    : :
    :
    : [blue]
    : printf does work in Turbo C++ 3.0, but it is a C function.
    : If you want C++, try this.
    : [code]
    : #include "iostream.h"
    :
    : int main(int argc, char* argv[])
    : {
    : char ch = 'H';
    : cout << ch << " dec Value=" << dec << (int)ch << endl;
    : cout << ch << " oct Value=" << oct << (int)ch << endl;
    : cout << ch << " hex Value=" << hex << (int)ch << endl;
    : return 0;
    : }
    : [/code]
    : [/blue]
    :
    :
    [green]...and if you want to do it in C, you can use printf for dec and hex, by binary is a little harder. You are going to have to learn about binary operators, AND, OR, XOR...I can't explain it now, but its more that a simple switch or thing...

    gotta go
    {2}rIng[/green]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories