Thread: Good interview Questions

  1. #1
    Registered User
    Join Date
    Aug 2009

    Good interview Questions

    int main()
            int x=5;
             printf("%d,%d,%dn",x,x< <2,x>>2);
    Answer: 5,20,1

    For the above code i complied and the answer also given

    MY Expected output was :5,5,1

    But after compling the output was :5,20,1

    I didn't understand the logic for that output obtained

    Can anybody give the reason for that output

    Thanking You,
    V.Rupendra Naidu

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    I would expect a compile error, but it is probably due to a typographical error on your part (x< <2 should be x << 2). Why do you think the second integer to be printed should be 5 instead of 20?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Aug 2009

    Thanks for reply

    i saw the solution that was given by you, i understand the logic .

    Thanks for spending your valuable time with me

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Good Programming schools are they out there???
    By jbarby in forum A Brief History of
    Replies: 14
    Last Post: 05-12-2009, 06:31 PM
  2. Any good tutorials?
    By kimmag in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2008, 07:44 AM
  3. What are some good books on C?
    By php111 in forum C Programming
    Replies: 9
    Last Post: 10-01-2008, 06:16 AM
  4. linked list recursive function spaghetti
    By ... in forum C++ Programming
    Replies: 4
    Last Post: 09-02-2003, 02:53 PM
  5. questions questions questions.....
    By mfc2themax in forum A Brief History of
    Replies: 1
    Last Post: 08-14-2001, 07:22 AM