Thread: stupid question of the day

  1. #1
    Registered User
    Join Date
    Feb 2003

    Question stupid question of the day


    What is the value of the following expression:



  2. #2
    samurai warrior nextus's Avatar
    Join Date
    Nov 2001
    1) dont you have a compiler to test it
    2) learn the ASCII table or have an ASCII table in handy

    well once again i am bored

    char x = 'g'-'a'+'A';
    cout << x << endl;
    //hmm it should output 'G' or 71 in ASCII
    nextus, the samurai warrior

  3. #3
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    You shouldn't need an ascii table.

    All lowercase letters are consecutive and all uppercase letters are consecutive so a lower case letter minus lowercase a will give you the offset in the alphabet (a is 0, b is 1 ... z is 25). So adding the offset to capital A will give you the capital version of the letter.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stupid Question Probably
    By Kyrin in forum C Programming
    Replies: 2
    Last Post: 05-07-2006, 12:51 AM
  2. Replies: 7
    Last Post: 11-04-2005, 12:17 AM
  3. Stupid Question
    By digdug4life in forum C++ Programming
    Replies: 22
    Last Post: 05-17-2005, 11:43 AM
  4. stupid, stupid question
    By xelitex in forum C++ Programming
    Replies: 5
    Last Post: 12-22-2004, 08:22 PM
  5. Stupid question: What does Debugger do?
    By napkin111 in forum C++ Programming
    Replies: 6
    Last Post: 05-02-2002, 10:00 PM