what will be the value of g equal to minus minus k + 2 k + l equal to k l + + if k is 20 initially
Answers
Answer:
What will be the value of j = --k + 2k (l=k, l++) if k is 20 initially?
Ad by UPES
1 Answer
This is tagged C++ by OP, and in C++ j = --k + 2k (l=k, l++), as written, won’t compile because it has syntax errors (the number 2 cannot be followed by the letter k, and the letter k cannot be followed by a parenthesis if it names a variable)
Worse yet, any simple ways in which I can imagine it could be made to compile results in expressions that have no meaning: j = --k + 2 * k * (l=k, l++) and even simply --k + 2*k are meaningless: an attempt to modify and read the same variable without sequencing renders a C++ program (and a C program too) undefined. Like with division by zero, it can do anything whatsoever. If you get output at all, that output is as meaningless as the program.
modern compilers flag this problem with a warning that should always be treated as error (I’ll assume the intent was to write j = --k + 2 * k * (l=k, l++), but it’s exactly the same whatever it was meant to be, as you have both --k and k appear together like that
int j = --k + 2 * k * (l=k, l++);
^~~
clang - [Wandbox
prog.cc:4:13: warning: unsequenced modification and access to 'k' [-Wunsequenced]
int j = --k + 2 * k * (l=k, l++);
^ ~