Results 1 to 2 of 2

Thread: Get output as swap

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Geek_Guest
    Guest

    Get output as swap

    void main()
    {
    int a=27,b=46;
    a=1?a-(b=1?((a=1?a+b:0)-b):0):0;
    printf("a=%db=%d",a,b);
    }

    I got swap answer for 2 inputs.
    Result are a=46,b=27;
    I am not able to get output as swap when i read through scanf statements.
    i.e., scanf("%d%d",&a,&b);printf("a=%db=%d",a,b);

    Please help me what is the concepts behind this ?

    Question asked by visitor sasikumar


  2. #2
    Junior Member
    Join Date
    Nov 2007
    Answers
    2

    Re: Get output as swap

    hey buddy,

    I got the right output. I donno y u didnt get the rt o/p. this is my program.

    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    int a,b;
    clrscr();
    printf("enter a,b:");
    scanf("%d%d",&a,&b);
    a=1?a-(b=1?((a=1?a+b:0)-b):0):0;
    printf("a=%d b=%d",a,b);
    getch();
    }

    i tried with diff values and i got the desired o/p i mean swapped o/p.


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