Showing posts with label Logical Operators. Show all posts
Showing posts with label Logical Operators. Show all posts

Saturday, 22 October 2011

Predict the output or error(s) for the following:

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);

}

Answer:

0 0 1 3 1

Explanation :

Logical operations always give a result of 1 or 0 . And also the logical AND (&&) operator has higher priority over the logical OR (||)