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.

What is a output?. How will Come?.

This is a discussion on What is a output?. How will Come?. within the C and C++ forums, part of the Software Development category; 0 0 1 2 -1...

Go Back   Geeks Talk > Software Development > C and C++
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #21 (permalink)  
Old 07-11-2009
Junior Member
 
Join Date: Jul 2009
Location: pune
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
kharade Sagar M is on a distinguished road
Re: What is a output?. How will Come?.

0 0 1 2 -1
Reply With Quote
Sponsored Links
  #22 (permalink)  
Old 07-11-2009
Junior Member
 
Join Date: Jul 2009
Location: pune
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
kharade Sagar M is on a distinguished road
Re: What is a output?. How will Come?.

Quote:
Originally Posted by Golda View Post
main()
{
int i=5;
printf("%d%d%d%d%d",i++, i--, ++i, --i,i);
}
I got the output 45545. How it will come?...
the output is 5 6 6 5 5
Reply With Quote
  #23 (permalink)  
Old 07-11-2009
Junior Member
 
Join Date: Jan 2007
Location: Hyderabad
Posts: 11
Thanks: 4
Thanked 1 Time in 1 Post
harini_sree is on a distinguished road
Re: What is a output?. How will Come?.

0,0,1,3,0
is this correct
Reply With Quote
  #24 (permalink)  
Old 07-29-2009
Junior Member
 
Join Date: Jul 2009
Location: SN Road, Bolpur, Birbhum
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
TANMOYPALIT is on a distinguished road
Re: What is a output?. How will Come?.

the output will be 00131
All the effect will be occur at next statement because of post increment
the || operator is the last element and the value of l is 2 so that any value of the previous generation will be ommited and the value of m will be true i.e. 1
m=0||1 is 1
i=-1 --> 0
j=-1 --> 0
k=0 --> 1
l=2 --> 3
m = 1
Reply With Quote
  #25 (permalink)  
Old 08-13-2009
Junior Member
 
Join Date: Aug 2009
Location: India
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
zaster is on a distinguished road
Re: What is a output?. How will Come?.

Quote:
Originally Posted by kharade Sagar M View Post
the output is 5 6 6 5 5
The output for this expression is ambiguous. The ANSI C standard does not define the order of evaluation of arguments to a function. Hence, the output may vary depending on the compiler you use.
Reply With Quote
  #26 (permalink)  
Old 08-13-2009
Junior Member
 
Join Date: Aug 2009
Location: India
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
zaster is on a distinguished road
Re: What is a output?. How will Come?.

Quote:
Originally Posted by Golda View Post
what about this?
void main()
{
unsigned giveit=-1;
int gotit;
printf("%u ",++giveit);
printf("%u ",gotit=-giveit);
}
"giveit" has a bit pattern
Code:
11111111 11111111 11111111 11111111
Incrementing it by 1 gives you the following bit pattern
Code:
1 00000000 00000000 00000000 00000000
This 1 results from overflow, and is ignored. So, you effectively get a zero value on return
Reply With Quote
  #27 (permalink)  
Old 09-07-2009
Junior Member
 
Join Date: Sep 2009
Location: Bangalore
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
rsmadhu2008 is on a distinguished road
Re: What is a output?. How will Come?.

Quote:
Originally Posted by Golda View Post
main()
{
int i=-1,j=-1,k=0,l=2,m;
m=i++&&j++&&k++||l++;
printf("%d %d %d %d %d",i,j,k,l,m);
}
Output : 0 0 1 3 1
EXP : As the expression have 3 && operators at the begin it will check for all the case s ,& will get 0 as resultant wch is || with 1 (i.e.,2) So that m=0||1=1.
Reply With Quote
  #28 (permalink)  
Old 10-03-2009
Junior Member
 
Join Date: May 2009
Location: bangalore
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
lilliput2009 is on a distinguished road
Re: What is a output?. How will Come?.

i=0,j=0,k=1,l=3,m=0
Reply With Quote
  #29 (permalink)  
Old 10-03-2009
Junior Member
 
Join Date: Sep 2009
Location: vijayawada
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
mahammuda.begum is on a distinguished road
Re: What is a output?. How will Come?.

Quote:
Originally Posted by Golda View Post
what about this?
void main()
{
unsigned giveit=-1;
int gotit;
printf("%u ",++giveit);
printf("%u ",gotit=-giveit);
}
++giveit=2 n -gotit= -2
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 2 01-05-2008 04:40 AM
Input and output AnnieL4864 VB.NET 1 11-20-2007 05:12 AM
How many Classes in output JobHelper Java 7 06-12-2007 04:14 AM
Output Value bharathi_ark Testing Issues 5 12-27-2006 07:13 AM
Output Functions RyanJames C and C++ 5 12-20-2006 03:10 AM


All times are GMT -4. The time now is 02:30 PM.


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