...
DSSSB TGT 2021
November 16, 2023
Question 7962 – GATE 2017 [Set-2]
November 16, 2023
DSSSB TGT 2021
November 16, 2023
Question 7962 – GATE 2017 [Set-2]
November 16, 2023

Question 4275 – UGC NET CS 2005 june-paper-2

After 3 calls of the c function bug( ) below, the values of i and j will be :
int j=1;
bug( )
{
static int i=0; int j=0;
i++;
j++;
return (i);
}

Correct Answer: D

Question 11 Explanation: 
Step-1: Initially i=0 but given as static. The scope is lifetime.
Step-2: Call-1: i=1 and j=1
Call-2: i=2 and j=1 because ‘i’ is static ‘j’ is again become 0 when it starts new call.
Call-3: i=3 and j=1 because ‘i’ is static ‘j’ is again become 0 when it starts new call.
Note: A static ‘int’ variable remains in memory while the program is running.
A
i = 0, j = 0
B
i = 3, j = 3
C
i = 3, j = 0
D
i = 3, j = 1
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!