Prepare for your Next Interview
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 ...
|
|||
|
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 |
| Sponsored Links |
|
|||
|
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. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| 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 |