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.
Which of the Indian state _______ has the highest number of operational SEZ(Special Economic Zones)?
"Taare Zameen Par" movie is based on which learning disorder?
When was the eShram portal officially launched?
Where in India is the headquarters of Citibank India located?
What is the duration for which Mahila Samman Savings Certificate can be held?
Under which scheme is the use of Artificial Intelligence, big data, and remote sensing emphasized for modernizing agriculture?
Which one of the following tribes is not the native of Andaman and Nicobar Islands?
Siddhartha Gautama, the founder of Buddhism, was born in which location?Â
Where is Maharana Pratap Airport located?
What was the Real Name of Singer Kishore Kumar?