Geeks Talk

Prepare for your Next Interview




Get output as swap

This is a discussion on Get output as swap within the C and C++ forums, part of the Software Development category; 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 ...


Go Back   Geeks Talk > Software Development > C and C++

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 10-28-2007
Expert Member
 
Join Date: Feb 2007
Posts: 1,279
Thanks: 0
Thanked 168 Times in 139 Posts
Geek_Guest is on a distinguished roadGeek_Guest is on a distinguished road
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
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-19-2007
Junior Member
 
Join Date: Nov 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
ruler_of_doll is on a distinguished road
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.
Reply With Quote
Reply

  Geeks Talk > Software Development > C and C++


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
First output value is getting overwritten by second output Geek_Guest QTP 2 01-05-2008 04:40 AM
What is a output?. How will Come?. Golda C and C++ 19 11-27-2007 06:05 AM
what will be the output? mahesh9920 C and C++ 8 10-31-2007 05:30 PM
Swap two numbers Manojks Brainteasers 10 01-14-2007 04:54 AM
Output Value bharathi_ark Testing Issues 5 12-27-2006 07:13 AM


All times are GMT -4. The time now is 01:48 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved