Thread: multiplication without * & +

  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    5

    Exclamation multiplication without * & +

    Hello guys,i have faced a qs in a ainterview yesterday....I cant solve it ..........

    i take an input n(an integer no) from user.and i have to print o/p 2*n in the console without using + and * in the program....

  2. #2
    C lover
    Join Date
    Oct 2007
    Location
    Virginia
    Posts
    266
    It's hard to determine what you're asking for because of your grammar. I think you want this:

    Code:
    int n = 5;
    
    n <<= 1;
    Shifting to the left by one gives the affect of multiplying by two.

  3. #3
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Yog Sothoth!

    Will you please stop with the shotgun approach already? I'm seriously growing concerned that you are going to break the internet!

    Soma

  4. #4
    Registered User
    Join Date
    Aug 2010
    Posts
    5

    @Syscal

    thanks buddy...for ur reply...........

    bt i dont think there is any prob regarding my grammar except a spelling mistake......

    thanks.........

  5. #5
    C lover
    Join Date
    Oct 2007
    Location
    Virginia
    Posts
    266
    Quote Originally Posted by phantomotap View Post
    Yog Sothoth!

    Will you please stop with the shotgun approach already? I'm seriously growing concerned that you are going to break the internet!

    Soma
    If I could answer someones question, why wouldn't I? I only logged in to check for replies to my thread. If you aren't going to contribute to the thread then don't say anything at all. It's not like I'm on these forums 24/7 nor is it like I have 3829 post. Lets see me "break the internet".

  6. #6
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,534
    Quote Originally Posted by gourabbanik05 View Post
    thanks buddy...for ur reply...........

    bt i dont think there is any prob regarding my grammar except a spelling mistake......

    thanks.........
    Your original post is not exactly clear due, at least in part, to your use of text-speak. Is it really that hard to type full words, using proper capitalization?

  7. #7
    Registered User Char*Pntr's Avatar
    Join Date
    Sep 2007
    Location
    Lathrop, CA
    Posts
    198

    Red face

    I think Sycal's response was both informative and appropriate.

    How the hell can someone "break the internet" with 24 posts in 3 years, is beyond me. Syscal: we've both been on here for almost 3 years, and we can sort out the few Nazis that frequent here.

    Seig Heil! Guten tag. oh, I almost forgot:
    Code:
    MyPostCount++ ;

  8. #8
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    If I could answer someones question, why wouldn't I? I only logged in to check for replies to my thread. If you aren't going to contribute to the thread then don't say anything at all. It's not like I'm on these forums 24/7 nor is it like I have 3829 post. Lets see me "break the internet".
    O_o

    How the hell can someone "break the internet" with 24 posts in 3 years, is beyond me. Syscal: we've both been on here for almost 3 years, and we can sort out the few Nazis that frequent here.
    o_O



    Yog Sothoth!

    I think you two, Char*Pntr and Syscal, must be a little stupid.

    I WAS TALKING TO THE ORIGINAL POSTER!

    He has posted the same few questions in dozens of forums over the last few weeks, often posting multiples of the same question at the same time, has bumped decade old threads to ask one of the questions, has ignored every answer he has got, and generally been inflammatory where he has responded.

    Soma

  9. #9
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by gourabbanik05 View Post
    thanks buddy...for ur reply...........

    bt i dont think there is any prob regarding my grammar except a spelling mistake......

    thanks.........
    "Txt speek" is simply viewed as being very childish, as is an excess of dots. As Jim Raynor says: "Time to man up!"

    I've said to others before: Your compiler does not accept misspellings and bad syntax, so why should we?
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  10. #10
    C lover
    Join Date
    Oct 2007
    Location
    Virginia
    Posts
    266
    Quote Originally Posted by phantomotap View Post
    O_o



    o_O



    Yog Sothoth!

    I think you two, Char*Pntr and Syscal, must be a little stupid.

    I WAS TALKING TO THE ORIGINAL POSTER!

    He has posted the same few questions in dozens of forums over the last few weeks, often posting multiples of the same question at the same time, has bumped decade old threads to ask one of the questions, has ignored every answer he has got, and generally been inflammatory where he has responded.

    Soma
    Then you weren't very clear about it. Maybe a quote would have helped. The comment seemed to be towards me. Sorry then.

  11. #11
    Registered User Char*Pntr's Avatar
    Join Date
    Sep 2007
    Location
    Lathrop, CA
    Posts
    198

    My Apology to the entire Board

    It took me a few days to "pause and reflect" an angry exchange that I made on this thread.

    I almost used the word "responded to." No, it was hardly that. I reacted. In my reaction, I used unprofessional language that is completely unbecoming of the professionals on this board.

    To the people on this board, I am very sorry. I lost my temper when I thought a fellow member was being harassed.

    It took me a few days to consider. Tonight while eating dinner, I remembered something on this thread from Imalc.... that was "Time to Man Up."

    Tonight I realized, that it doesn't matter what whom said to who - or who the original flame was directed to.

    I realized tonight, that it was I, who was wrong with my reaction. Since then, I have been monitoring a thread on the C-board, a bit heated at times, but they always quote the source they are replying to. But everyone there acts professionally.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 07-15-2010, 07:53 PM
  2. Multiplication table (need guide)
    By naspek in forum C Programming
    Replies: 21
    Last Post: 07-23-2009, 06:26 AM
  3. Help me find a multiplication toy.
    By QuestionC in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 08-24-2007, 12:27 PM
  4. ...multiplication using stacks
    By iiwhitexb0iii in forum C Programming
    Replies: 1
    Last Post: 10-09-2006, 01:28 AM
  5. multiplication table
    By SpEkTrE in forum C Programming
    Replies: 2
    Last Post: 12-09-2003, 04:46 PM