Pointers

Test - 1 2025

Q.1 Output of the following code:

int main()
{
    int i=3, *j, k;
    j = &i;
    cout<<i**j*i+*j;
    return 0;
}
27 30
3 9

Q.2 What will be the output?

int main()
{
    int ***r, **q, *p, i=8;
    p = &i;
    q = &p;
    r = &q;
    cout<<*p<<**q<<***r;
    return 0;
}
4000,4001,4002 4000,4000,4000
8,8,8 8,9,10

Q.3 What does the following statement mean?

int (*fp)(char*)
pointer to a pointer pointer to function taking a char* argument and returns an int
pointer to an array of chars function taking a char* argument and returning a pointer to int

Q.4 What is the output of this program?

 #include <iostream>
    using namespace std;
    int main()
    {
        char arr[20];
        int i;
        for(i = 0; i <10; i++)
            *(arr + i) = 65 + i;
        *(arr + i) = '\0';
        cout << arr;
        return(0);
    }
ABCDEFGHIJ AAAAAAAAAA
JJJJJJJJ none of the mentioned

Q.5 Which of the following is illegal?

int *ip; string s, *sp = 0;
int i; double* dp = &i; int *pi = 0;

Q.6 Which of the below statements are false?

it is possible to create a pointer to a reference. we can't have array of references.
we can't have reference to a reference. it is possible to have pointer to a pointer.

Q.7 What is size of generic pointer in c?

null 0
1 2

Q.8 When does the void pointer can be dereferenced?

when it doesn’t point to any value when it cast to another type of object
using delete keyword None of these

Q.9 A void pointer cannot point to which of these?

methods in c++ class member in c++
both a & b none of the mentioned

Q.10 What is the output of this program?

#include < iostream >
using namespace std;
int main()
{
char *ptr;
char Str[] = "abcdefg";
ptr = Str;
ptr += 5;
cout << ptr;
return 0;
}
fg cdef
defg abcd

Advertisment

Share


Advertisement