Results 1 to 16 of 16

Thread: c#

  1. #1
    Junior Member
    Join Date
    Aug 2008
    Answers
    1

    c#

    what will be the o/p of following?
    int x=10;
    Console.Writeline("(2)(1)(0)",++x,x++,x++);


  2. #2
    Junior Member
    Join Date
    Jun 2008
    Answers
    1

    Re: c#

    what will be the o/p of following?
    int x=10;
    Console.Writeline("(2)(1)(0)",++x,x++,x++);
    answer 12 11 11


  3. #3
    Junior Member
    Join Date
    Sep 2008
    Answers
    1

    Re: c#

    coorect Answer is 11


  4. #4
    Junior Member
    Join Date
    Feb 2006
    Answers
    4

    Re: c#

    It should be 11,10,10

    as first time is goes to ++x, x will become 11
    and when it goes to x++, it will remain 10, as the value of x is 10


  5. #5
    Junior Member
    Join Date
    Sep 2008
    Answers
    3

    Re: c#

    execution starts from right side....x++....10.... x becomes 11
    x++....11.... x becomes 12
    ++x...pre increment i,e x becomes 13
    output is 10,11,13


  6. #6
    Junior Member
    Join Date
    Sep 2008
    Answers
    3

    Re: c#

    the answear is 11


  7. #7
    Junior Member
    Join Date
    Oct 2008
    Answers
    2

    Re: c#

    it should be 10 , 11 , 13


  8. #8
    Junior Member
    Join Date
    Oct 2008
    Answers
    1

    Re: c#

    Quote Originally Posted by SOMRAJ View Post
    what will be the o/p of following?
    int x=10;
    Console.Writeline("(2)(1)(0)",++x,x++,x++);
    The answer is 12


  9. #9
    Junior Member
    Join Date
    Nov 2008
    Answers
    1

    Re: c#

    the answer is 10 11 13


  10. #10
    Junior Member
    Join Date
    Nov 2008
    Answers
    2

    Re: c#

    Quote Originally Posted by SOMRAJ View Post
    what will be the o/p of following?
    int x=10;
    Console.Writeline("(2)(1)(0)",++x,x++,x++);



  11. #11
    Junior Member
    Join Date
    Nov 2008
    Answers
    1

    Re: c#

    Quote Originally Posted by SOMRAJ View Post
    what will be the o/p of following?
    int x=10;
    Console.Writeline("(2)(1)(0)",++x,x++,x++);
    The answer is (2)(1)(0)


  12. #12
    Junior Member
    Join Date
    Nov 2008
    Answers
    3

    Re: c#

    11 11 12 will be the answer...


    of ++x,x++,x++ consider as
    1 2 3 x's

    for 1 the x value will be increased to 11 and is displayed
    for 2 the x value is first displayed as 11 and then increased to 12
    for 3 the x value is first displayed as 12 and then increased to 13

    To Test... in C#
    int x = 10;
    Response.Write(++x + "--" + x++ + "--" + x++);
    Response.Write("At last X value is "+x);

    Answer:
    11--11--12 At last X value is 13

    Last edited by adib4u2000; 11-20-2008 at 06:43 PM.

  13. #13

    Re: c#

    it Should be 11,11,12 and in last x shuld be equal to 13


  14. #14
    Junior Member
    Join Date
    Jan 2009
    Answers
    2

    Re: c#

    Nothing Because there is no such function Writeline , you have to use WriteLine
    If you use WriteLine , you will receive
    (2)(1)(0)


  15. #15

    Re: c#

    The correct ans. is 10,11,13....
    Bcoz first time it goes on 2nd index means x++, so first it assign or print a value thai is 10.
    after that it increment x value by 1 so now x = 11,
    then again it print 11 and then it incremented so x= 12,
    then first it increment so x=13 and it print.

    so, final ans. is 10,11,13.


  16. #16
    Junior Member
    Join Date
    Feb 2009
    Answers
    1

    Re: c#

    Err, its (2)(1)(0) because there are not any placeholders.

    It should be {2}{1}{0}.

    Which results in 12,11,11.

    First operation = 11;
    Second Operation = 12; but doesn't get incremented until the operation completes so output is 11.
    Third Operation = 13; but current value is 12.


  17.  Sponsored Ads
    Ad


     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact