This week's giveaways are in the MongoDB and Jobs Discussion forums.
We're giving away four copies of Mongo DB Applied Patterns and 4 resume reviews from Five Year Itch and have the authors/reps on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes help me solving this question in C Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

help me solving this question in C

Jatin sachdev
Ranch Hand

Joined: Jan 21, 2010
Posts: 57
Q:What is the output :

main()
{
int var1=4,var2=6;
var2=var2 || var++ && printf("Computer World");
printf("%d %d",var1,var2);
}

the answer coming out is :4 1

My problem is how this is executing...

If you are going to say that this is SHORT CIRCUIT then my question to you is :
How the precedence is being followed in this expression?
Because in this precedence should be like:
++
&&
||

Do consider this also
2+3*4+6 since *(multiply) has higher precedence than + thus we calculate * before +
Same must be applied in the above program if we go by the precedence...
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4163
    
    3

Why the double post in a forum where a C related question is so obviously off topic?
http://www.coderanch.com/t/506619/ol/


luck, db
There are no new questions, but there may be new answers.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32599
    
    4
You beat me by 17 minutes, DB, and thank you for noticing.

Jatin sachdev, you should by now know to use one forum. Closing thread.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: help me solving this question in C
 
Similar Threads
How Instance variables get Default values
Byte -- what's going on
Problem in C
How to add two variables in XSLT
<c:forEach> to iterate a collection