1.
If x is greater than 0, what is the time complexity of the following C function:
 
int recursive(mt x) {
    if (x == 1)
        return (1);
    else
        return (recursive(x - 1) + recursive(x - 1));
}
2.
In the following C program, the f function returns ___________________________ for large values of y.
 
float f(float x, int y) {
    float p, s;
    int i;

    for (s = 1, p = 1, i = 1; i < y; i++) {
        p *= x / i;
        s += p;
    }

    return s;
}
3.
In the following C program, CellNode represents a node in a binary tree. When a pointer to the binary tree root is passed as its argument, the value returned by GetValue() is equal to the _____________.
 
struct CellNode {
    struct CellNOde * leftChild;
    int element;
    struct CellNode * rightChild;
};

int GetValue(struct CellNode * ptr) {
    int value = 0;
    if (ptr != NULL) {
        if ((ptr - > leftChild == NULL) && (ptr - > rightChild == NULL))
            value = 1;
        else
            value = value + GetValue(ptr - > leftChild) + GetValue(ptr - > rightChild);
    }
    return (value);
}
4.
Consider the command ./a.out John loves you. Assume that a.out is an executable. If we execute ./a.out John loves you and try to access the command line arguments as shown in the example C code below, which of the following characters would be printed if we were to print argv[1][2] ?
Example C code to understand the question.
 
#include
int main(int argc, char * argv[]) {
    // What would be the value of argv[1][2] ?
    printf("%c
", argv[1][2]);
}
5.
What is the return value of f(x, x), if the value of x is initialized to 5 before the call?
 
int f(int & x, int c) {
    c = c - 1;
    if (c == 0) return 1;
    x = x + 1;
    return f(x, c) * x;
}
6.
What will be the output of the following C code:
# include
# include

int main() {
    union test {
        int i;
        float f;
        char c;
    };
    union test * t;
    t = (union test * ) malloc(sizeof(union test));
    t - > f = 10.10 f;
    printf("%f", t - > f);

    return 0;
}
7.
If the malloc() function successfully allocates memory, it returns the number of bytes it has allocated.
8.
What is the output of the following C code:
#include

int main() {
    static int arr[] = {
        0,
        1,
        2,
        3,
        4
    };
    int * p[] = {
        arr,
        arr + 1,
        arr + 2,
        arr + 3,
        arr + 4
    };
    int ** ptr = p;
    ptr++;
    printf("%d, %d, %d
", ptr - p, * ptr - arr, ** ptr);
    * ptr++;
    printf("%d, %d, %d
", ptr - p, * ptr - arr, ** ptr);
    *++ptr;
    printf("%d, %d, %d
", ptr - p, * ptr - arr, ** ptr);
    ++ * ptr;
    printf("%d, %d, %d
", ptr - p, * ptr - arr, ** ptr);

    return 0;
}
9.
If the array begins at 65472 and the size of the integer is 2 bytes, what is the output of the following C code:
#include <stdio.h>

int main()
{
int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0};
printf("%u, %u
", a + 1, &a + 1);
return 0;
}
10.
In C, which of the following statements mentioning the name of the array does not yield the base address:

  1. If the array name is used with the size of the operator.
  2. If the array name is an operand of the & operator.
  3. If the array name is passed to the scanf() function.
  4. If the array name is passed to the printf() function.