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 June 2022, the Supreme Court directed that every protected forest, national park and wildlife sanctuary across the country should have a mandatory e...
Which of the following has the highest salinity?
Iron age is so named because during this time iron mostly replaced _________ in implements and weapons, beginning in the Middle East and South-eastern E...
Who is the chairman of the State Planning Board?
Consider the following statements regarding the Commission and Committee of Parliament on the official languages.
1. It shall be the duty of the ...
P. Q, R, S, T, U, V and W are sitting in a row facing North. P and S are neighbours; W is a neighbour of both Q and U; T is a neighbour of R and V. If t...
Where is the headquarters of the International Olympic Committee (IOC) situated?
In which of the following dances from Assam do the movements by the dancers resemble butterflies and birds?
Using all the letters of the word ‘Sunday’, how many different words can be formed?
Consider the following statement about ICC Men's Cricket World Cup 2023:
1. Virat Kohli has been named as the player of the tournament.
2....