main()
{
int i = 1;
int num[] = {1,2,3,4};
num[i] = i++;
printf("%d", num[i]);
}
what will be the output?
}
Answers were Sorted based on User's Feedback
Answer / pragathi
3 is the answer bcoz
i=1
num[i]=i++;
num[1]=2;
here i=2
printf("%d", num[2]);
here 3 is there at position 2 .
so answer is 3
Is This Answer Correct ? | 19 Yes | 3 No |
Answer / xyz
the answer will be 3 b'coz whatever the "num[i] = i++;"
this expression the output will be depend's on "i" and
at last i will be 2 and num[2]=3 which is the answer.
Is This Answer Correct ? | 8 Yes | 1 No |
Answer / tk
Answer is :: 3
Explanation::
main()
{
int i = 1;
int num[] = {1,2,3,4};
num[i] = i++; // Here i = 1, so num[1] = 1; and num =
{1,1,3,4}
// After the execution of this statement the value of i
will be 2 (as i++)
printf("%d", num[i]); // num[2] = 3 so answer is 3
}
}
Is This Answer Correct ? | 5 Yes | 0 No |
Answer / vinay
Idiots please don't give wrong answers. While you answer
the questions, please check the output practically and post
Is This Answer Correct ? | 5 Yes | 1 No |
Answer / anusha raykar
Please dont answer with blind mind.
Answer is= 3
100%
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / vijay
expression likes
num[i]=i++;
are always compiler dependent.
it is a bad programing to use such expression.
Is This Answer Correct ? | 9 Yes | 7 No |
Write a program to find the number of times that a given word(i.e. a short string) occurs in a sentence (i.e. a long string!). Read data from standard input. The first line is a single word, which is followed by general text on the second line. Read both up to a newline character, and insert a terminating null before processing. Typical output should be: The word is "the". The sentence is "the cat sat on the mat". The word occurs 2 times.
What is d'n in c?
what are the difference between ANSI C and Let Us c and Turbo C
pgm to find number of words starting with capital letters in a file(additional memory usage not allowed)(if a word starting with capital also next letter in word is capital cann't be counted twice)
Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?
How does #define work?
Why is C language being considered a middle level language?
What is the result main() { char c=-64; int i=-32 unsigned int u =-16; if(c>i){ printf("pass1,"); if(c<u) printf("pass2"); else printf("Fail2");} else printf("Fail1); if(i<u) printf("pass2"); else printf("Fail2") } a)Pass1,Pass2 b)Pass1,Fail2 c)Fail1,Pass2 d)Fail1,Fail2 e)none
Difference between strcpy() and memcpy() function?
explain what is a newline escape sequence?
nic scientist exam
How important is structure in life?