Question
Consider the following code snippet. What is the output
of the program? #include < stdio.h > int main ( ) { int arr[5] = {1, 2, 3, 4, 5}; int *ptr = arr; ptr + = 2; printf("%d", *ptr); return 0; }Solution
In the code, ptr initially points to the first element of the array arr. The line ptr += 2; moves the pointer two positions ahead, meaning ptr now points to the third element of the array, which is 3. Therefore, *ptr dereferences the pointer to print the value 3. Why Other Options are Wrong: a) 1 is the first element, but the pointer has moved past it. b) 2 is the second element, but ptr skips over it. d) 4 is the fourth element, but ptr stops at the third. e) 5 is the fifth element, beyond where ptr is pointing.
- If 11 December 2009 is a Friday, then what will be the day of the week on 18 December 2014? 
- If POSITIVE is coded as OPISITEV in a certain coded language, then how will be MODERATE coded in that language? 
- Select the letter-cluster that will replace the question mark (?) in the given series and make it logically complete. - FRP, HTR, JVT, ?, NZX 
- In a certain code language, 'CHILD' is written as ‘6169248' and 'GUEST' is written as '142153840'. How will 'BOOK' be written in that language? 
- Statements: - All beards are nails. Some nails are rings. - All rings are pendants. - Conclusions: - I. All rings can never be n... 
- Given below is a statement followed by possible reasons. Read the statement carefully and decide which one explains the event observation information gi... 
- If '+' means '÷' , '–' means '+' , '×' means '–' and '÷' means '×', then what will come in place of (?) in the given equation? - 8 ÷ 5 –... 
- The following question is based on the given diagram. The triangle represents ‘teachers’, the circle represents ‘players’, and the rectangle rep... 
- Change the question mark with the option that follows the applied logic in the first pair. - 114: 24 :: 394: ?? 
- Select the correct mirror image of the given combination when the mirror is placed at MN as shown.