Geeks Talk

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.

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 swap answer for 2 inputs. Result are a=46,b=27; I am not able to get output as swap when i read ...

Go Back   Geeks Talk > Software Development > C and C++
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #1 (permalink)  
Old 10-28-2007
Expert Member
 
Join Date: Feb 2007
Posts: 1,279
Thanks: 0
Thanked 198 Times in 157 Posts
Geek_Guest has a spectacular aura aboutGeek_Guest has a spectacular aura aboutGeek_Guest has a spectacular aura about
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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


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


All times are GMT -4. The time now is 03:35 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2005 - 2010 GeekInterview.com. All Rights Reserved