Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
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 swap answer for 2 inputs. Result are a=46,b=27; I am not able to get output as swap when i read ...
|
|||||||
|
|||
|
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 | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| First output value is getting overwritten by second output | Geek_Guest | QTP | 3 | 12-17-2009 10:32 AM |
| What is a output?. How will Come?. | Golda | C and C++ | 28 | 10-03-2009 07:21 AM |
| Swap two numbers | Manojks | Brainteasers | 11 | 07-15-2009 11:22 AM |
| what will be the output? | mahesh9920 | C and C++ | 8 | 10-31-2007 04:30 PM |
| Output Value | bharathi_ark | Testing Issues | 5 | 12-27-2006 06:13 AM |