int a=5, printf("%d,%d,%d,%d", ++a,++a,++a,++a);
puts( "Not a question!" );
\(\color{darkgreen}{~\huge\star~``Welcome~to~Open~Study~!!"~\star~}\) > \(Turbo~C~Compiler....~I~think~So~!!\) \(Case~1:\) it is undefined behavior to modify a value more than once between sequence points, and the arguments to a function are not separated by sequence points. So the ++a and the a++ there is a problem. \(Case~2:\) The format string says there are 5 arguments, but you've only provided 3. So printf will be looking for arguments that aren't there. This is also undefined behavior. \(Finally,\) Order of evaluation of arguments to a function is unspecified. So even if your format string specified the correct number of arguments, there is no telling what the values of each argument will be in this case. \(Hope~it~helps~!!\) Don't Forget, \(Appreciate~the~Best~Answer\) with a click on \(\color{purple}{"Best Response"}\) Button Too ! \(\color{darkgreen}{~''Nice~To~Meet~You~!!"}\) @yaminiveduri
\(Have~A~look~at~these~wonderful~ideas~too~!!~From~Where~I~Just~Concluded~!!\) \(Ref:\) http://www.allinterview.com/showanswers/99555.html
you are using printf function and printf always evaluates its arguments by arranging them on stack from left to right. so, using stack , the last argument is evaluated first and the first argument is evaluated lastly. and then gives the output. so we are using same variable "a" here agagin and again. By using above, last ++a is evaluated first. so a=6 .. ... first ++a is evaluated lastly. so a=9. now printf gives its output and as the current value of a becomes 9 so output:9,9,9,9
Join our real-time social learning platform and learn together with your friends!