#include<stdio.h> void main() { int n=5; if(n==5?printf("Hallo"):printf("Hai"),printf("Bye")); } The output of the above code is HalloBye..But I am not able to debug it..I know that ternary has precedence over comma operator but i am stuck at which operand will go with which operator..Can someone please help

Member Avatar
Member Avatar
-1 forum 9

int m= i++ || ++j && k--; where i=2, j=3, amd k=5; acooridng to me, it will be executed left to right and then values of m=1, i=3, j=3 and k=5. but i have seen that precednace of && is more than || , than so how this expression is parenthezed by compiler to execute it ? as it goes to i++, and since it is non-zero , then it dont need to check after this, so stoped there. (this is what i thought before reading that precdance of && is more than || ). so what is wrong here …

Member Avatar
Member Avatar
+0 forum 14

Hi, I am just trying to do some program on arithmetic expression parsing. So i want to store my operator precedence table in the program somehow. I could use a multidimensional array, but that would be inefficient i guess. Another idea i have is to use a HashTable, where the keys will be integers spcifying the precedence order, and the value can be an array or better an arraylist which can have the elements with the same precedence. But still this will involve a lot of looping around as the precedence value, is the key and not the value. Does …

Member Avatar
Member Avatar
+0 forum 8

main() { int x=20,y=35; x=y++ + x++; y= ++y + ++x; printf(“%d%dn”,x,y); } what would be the output? can some one explain it with associativity and operator precendence

Member Avatar
Member Avatar
+0 forum 1

let say i have an expression like the one below, I guess it goes from left to right? if(exp1 && (exp2 && exp3 || exp4) || exp5)

Member Avatar
Member Avatar
+0 forum 3

here's the infix expression: [B]EXAMPLE 1[/B] a/(b+c)*d according to me, if [B]*[/B] is given higher precedence then [B]/[/B] , then this should be the postfix expression: [B]1) abc+d*/ [/B] if / has higher priority then * , then: [B]2) abc+/d*[/B] [B]question 1: [/B]which is correct?? 1 or 2 ? according to this link, [URL="http://www.cs.man.ac.uk/~pjj/cs212/fix.html"]http://www.cs.man.ac.uk/~pjj/cs212/fix.html[/URL] [B]EXAMPLE 2[/B] a*(b+c)/d gives abc+*d/ , in which case i think its assumed : [B]1)[/B]either * and / are given same priority, and the algo when checking priority, pops out the operator on stack if the priority of operator on stack[top] >= operator scanned from infix …

Member Avatar
Member Avatar
+0 forum 3

b=c/d++; In this, first d is incremented (because ++ has a higher priority than / or =), but c is divided by the unincremented value of d. Thus, the order of evaluation in this case is well-defined. But if we had written the above as: b=(c)/(d++) then which operand ( c or d++ ) is evaluated first is undefined. Isn't this what Dennis Ritchie meant in his book when he said :"C, like most languages, does not specify the order in which the operands of an operator are evaluated." ?. In the first case, the order in which the operands …

Member Avatar
Member Avatar
+0 forum 19

hello, there is a main xslt-script with a "do_this_and_that"-template. in an from the main included script ther is such "do_this_and_that"-template too. is it possible to call the "do_this_and_that"-template from the main by this included "do_this_and_that"-template? many thanks for your answer(s)

Member Avatar
Member Avatar
-1 forum 1

This is a catalogue of some experiments on just two aspects of undefined behaviour. This was inspired by yet another long bout of explanation in a recent thread, so I thought it was time to dust off a bunch of compilers, and compare. This is the test code. [code] #include <stdio.h> int f1 ( void ) { printf( "f1 called = 1\n" ); return 1; } int f2 ( void ) { printf( "f2 called = 2\n" ); return 2; } int f3 ( void ) { printf( "f3 called = 3\n" ); return 3; } int f4 ( void …

Member Avatar
Member Avatar
+4 forum 5

The End.