...
UGC NET CS 2006 Dec-paper-2
April 8, 2025
UGC NET CS 2006 Dec-paper-2
April 8, 2025
UGC NET CS 2006 Dec-paper-2
April 8, 2025
UGC NET CS 2006 Dec-paper-2
April 8, 2025

UGC NET CS 2006 Dec-paper-2

Question 13
int arr[ ]={1, 2, 3, 4}
int count;
incr( )
{
return ++count;
}
main( )
{
arr[count++]=incr( );
printf(“arr[count]=%d\n”, arr[count]);
}
The value printed by the above program is ​ :
A
1
B
2
C
3
D
4
Question 13 Explanation: 
Step-1: Before printing the arr[count] value, the variable “count” is incremented twice then count =2
Step-2: arr[2] value is 3 , So, it will print the value “3”.
Method-2:
→ The function incr() is executed as it is first statement.
→ Count is global variable whose initial value is 0 ,the function definition increments the count value and returns value “1” to the main function.
→ Again the main function, the expression arr[count++] , here count variable operation is post increment so arr[1] will store the value “1”.
→ After that statement , count value becomes “2” as it is incremented in the previous statement (total two increments).
→ Before printing the arr[count] value, the variable “count” is incremented twice then count =2
→ arr[2] value is 3 , so it will print the value “3”.
Correct Answer: C
Question 13 Explanation: 
Step-1: Before printing the arr[count] value, the variable “count” is incremented twice then count =2
Step-2: arr[2] value is 3 , So, it will print the value “3”.
Method-2:
→ The function incr() is executed as it is first statement.
→ Count is global variable whose initial value is 0 ,the function definition increments the count value and returns value “1” to the main function.
→ Again the main function, the expression arr[count++] , here count variable operation is post increment so arr[1] will store the value “1”.
→ After that statement , count value becomes “2” as it is incremented in the previous statement (total two increments).
→ Before printing the arr[count] value, the variable “count” is incremented twice then count =2
→ arr[2] value is 3 , so it will print the value “3”.

Leave a Reply

Your email address will not be published. Required fields are marked *