File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
    Bookmark Topic Watch Topic
  • New Topic

help me solving this question in C

 
Jatin sachdev
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Why the double post in a forum where a C related question is so obviously off topic?
http://www.coderanch.com/t/506619/ol/
 
Campbell Ritchie
Sheriff
Pie
Posts: 47284
52
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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://aspose.com/file-tools
    Bookmark Topic Watch Topic
  • New Topic