Programming
February 13, 2024
Question 9873 – Programming
February 13, 2024
Programming
February 13, 2024
Question 9873 – Programming
February 13, 2024

Programming

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

A
10
B
4
C
6
D
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.
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.

Leave a Reply

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