Pointers

1

What is the output of this program?

1.
    #include 
2.    
    using namespace std;
3.    
    int main()
4.    
    {
5.    
        char *ptr;
6.        
        char Str[] = "abcdefg";
7.        
        ptr = Str;
8.        
        ptr += 5;
9.        
        cout << ptr;
10.        
        return 0;
11.        
    }

A. fg
B. cdef
C. defg
D. abcd

2

What is the output of this program?

1.
    #include 
2.    
    using namespace std;
3.    
    int main()
4.    
    {
5.    
        char arr[20];
6.        
        int i;
7.        
        for(i = 0; i < 10; i++)
8.        
            *(arr + i) = 65 + i;
9.            
        *(arr + i) = '\0';
10.        
        cout << arr;
11.        
        return(0);
12.        
    }

A. ABCDEFGHIJ
B. AAAAAAAAAA
C. JJJJJJJJ
D. none of the mentioned

3

The correct statement for a function that takes pointer to a float, a pointer to a pointer to a char 

and returns a pointer to a pointer to a integer is

A. int **fun(float**, char**)
B. int *fun(float*, char*)
C. int ***fun(float*, char**)
D. int ***fun(*float, **char)

4

What is the output of this program?

 
1.
    #include 
2.    
    using namespace std;
3.    
    int main()
4.    
    {
5.    
        int a = 5, b = 10, c = 15;
6.        
        int *arr[ ] = {&a, &b, &c};
7.        
        cout << arr[1];
8.        
        return 0;
9.        
    }
A. 5
B. 10
C. 15
D. it will return some random number

5

What will happen in this code?
 int a = 100, b = 200;
 int *p = &a, *q = &b;
 p = q;

A. b is assigned to a
B. p now points to b
C. a is assigned to b
D. q now points to a