Programming
February 13, 2024Question 9873 – Programming
February 13, 2024Programming
|
Question 30
|
The value of j at the end of the execution of the following C program.
int incr(int i)
{
static int count = 0;
count = count + i;
return (count);
}
main()
{
int i,j;
for (i = 0; i <= 4; i++)
j = incr(i);
}
is
|
10
|
|
|
4
|
|
|
6
|
|
|
7
|
Question 30 Explanation:
At i=0; count=0
i=1; count=1
i=2; count=3
i=3; count=6
i=4; count=10
It return count value is 10.
i=1; count=1
i=2; count=3
i=3; count=6
i=4; count=10
It return count value is 10.
Correct Answer: A
Question 30 Explanation:
At i=0; count=0
i=1; count=1
i=2; count=3
i=3; count=6
i=4; count=10
It return count value is 10.
i=1; count=1
i=2; count=3
i=3; count=6
i=4; count=10
It return count value is 10.
