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.
- In each sentence below four words have been printed in bold which are labeled as (A), (B), (C) and (D) One of these words may be misspelt or inappropriate ...
- In the sentence given below four words have been printed in bold which are labeled as (A), (B), (C) and (D) One of these words may be misspelt or inappropr...
The SpaceX CEO claimed to have photography evidence of the experiment , describing a surprisingly calm seal
wearing headphones while strappe...
Four words are listed below. Select the CORRECTLY spelt word.
1) asociation
2) alliance
3) impliment
4) lothe
The building was so old that its walls were cracked bad.
- In each sentence below four words have been printed in bold which are numbered (1), (2), (3) and (4) One of these words may be misspelt or inappropriate in...
In each group, one word is correctly spelt. Find the correct word.
Select the word with the correct spelling.
U.S. President Donald Trump has defended his decision not to hold Saudi rulers acountable in the killing of dissident journalist Jamal Khashoggi.