main()
{
int i = 1;
int num[] = {1,2,3,4};
num[i] = i++;
printf("%d", num[i]);
}
what will be the output?
}
Answer Posted / james holdcroft
The output will be 1 or 3, depending on the compiler.
Quoting from "The C Programming Language, Second Edition"
by Kernighan and Ritchie:
C, like most languages, does not specify the order in which
operands of an operator are evaluated. (The exceptions are
&&, ||, ?:, and ','.)
...
One unhappy situation is typified by the statement
a[i] = i++;
The question is whether the subscript is the old value of i
or the new. Compilers can interpret this in different
ways, and generate different answers depending on their
interpretation.
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Explain continue keyword in c
What does c value mean?
to find the closest pair
How can I find the modification date and time of a file?
How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?
What is Dynamic memory allocation in C? Name the dynamic allocation functions.
What the advantages of using Unions?
The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?
in iso what are the common technological language?
Explain what are multibyte characters?
How do we print only part of a string in c?
how is the examination pattern?
What are the header files used in c language?
What does the && operator do in a program code?
Explain the properties of union. What is the size of a union variable