# C Language | Set 1

1)
```int a, b, c = 0;
void prtFun (void);
int main ()
{
static int a = 1; /* line 1 */
prtFun();
a += 1;
prtFun();
printf ( "%d %d " , a, b) ;
}

void prtFun (void)
{
static int a = 2; /* line 2 */
int b = 1;
a += ++b;
printf (" %d %d " , a, b);
}
```

1. 3 1 5 2 5 2
2. 4 2 6 2 2 0
3. 4 2 6 1 6 1
4. 3 1 4 1 4 2

2)
`for (i = n, j = 0; i >0; i /= 2, j += i); `
Let val(j) denote the value stored in the variable j after termination of the for loop. Which one of the following is true?

1. val(j) = Θ(logn)
2. vaI(j) = Θ(sqrt(n))
3. val(j) = Θ(n)
4. (D) val(j) = Θ(nlogn)

3)
```int f(int n)
{
static int i = 1;
if (n >= 5)
return n;
n = n+i;
i++;
return f(n);
}
```
The value returned by f(1) is

1. 5
2. 6
3. 7
4. 8

4)
```main()
{
int x, y, m, n;
scanf ("%d %d", &x, &y);
/* x > 0 and y > 0 */
m = x; n = y;
while (m != n)
{
if(m>n)
m = m - n;
else
n = n - m;
}
printf("%d", n);
}
```

1. x + y using repeated subtraction
2. x mod y using repeated subtraction
3. the greatest common divisor of x and y
4. the least common multiple of x and y