True / False Questions

Question 1 :

Are the expression *ptr++ and ++*ptr are same?


A). True
B). False
Answer : Option B

Explanation :

*ptr++ increments the pointer and not the value, whereas the ++*ptr increments the value being pointed by ptr


Question 2 :

Will the program compile?

#include
int main()
{
    char str[5] = "IndiaPARINAM";
    return 0;
}


A). True
B). False
Answer : Option A

Explanation :

C doesn't do array bounds checking at compile time, hence this compiles.

But, the modern compilers like Turbo C++ detects this as 'Error: Too many initializers'.

GCC would give you a warning.


Question 3 :

The following program reports an error on compilation.

#include
int main()
{
    float i=10, *j;
    void *k;
    k=&i;
    j=k;
    printf("%f\n", *j);
    return 0;
}


A). True
B). False
Answer : Option B

Explanation :

This program will NOT report any error. (Tested in Turbo C under DOS and GCC under Linux)

The output: 10.000000


Question 4 :

Are the three declarations char **apple, char *apple[], and char apple[][] same?


A). True
B). False
Answer : Option B