Exercise

1.What is the output of this program?
Note:Includes all required header files

using namespace std;
int main()
{
int x = 1, y = 3, z = 5;
int *find[ ] = {&x, &y, &z};
cout << find[1];
return 0;
}

A. 1
B. 3
C. 5
D. it will return some random number

View Answer


2.What is the output of this program?
Note:Includes all required header files

using namespace std;
int main()
{
char find[20];
int i;
for(i = 0; i < 10; i++)
*(find + i) = 65 + i;
*(find + i) = '\0';
cout << find;
return(0);
}

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

View Answer


3.What is the output of this program?
Note:Includes all required header files

using namespace std;
int main()
{
char *ptr;
char Str[] = "abcdefg";
ptr = Str;
ptr += 5;
cout << ptr;
return 0;
}

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

View Answer


4.Which of the following statement is correct about the program given below?
Note:Includes all required header files

using namespace std;
int main()
{
int a[2][4] = {1, 2, 3, 4, 5, 6, 7, 8};
cout << *(a[1] + 2) << *(*(a + 1) + 2) << 2[1[a]];
return 0;
}

A.5 6 7
B. 7 7 7
C. 8 8 8
D. Compile time error

View Answer


5.Which of the following is true about the following program
Note:Includes all required header files

using namespace std;
int main()
{
int i;
char *find[] = {"C", "C++", "Java", "VBA"};
char *(*ptr)[4] = & find;
cout << ++(*ptr)[2];
return 0;
}

A. ava
B. java
C. c++
D. compile time error

View Answer


6.What will be the output of this program?
Note:Includes all required header files

using namespace std;
int main()
{
int find[] = {1, 2, 3, 4};
int *p = (find + 1);
cout << *p;
return 0;
}

A. 1
B. 2
C. 3
D. 4

View Answer


7.What will be the output of this program?
Note:Includes all required header files

using namespace std;
int main()
{
int find[] = {1, 2, 3, 4};
int *p = (find + 1);
cout << find;
return 0;
}

A. 1
B. 2
C. address of find
D. 4

View Answer


8. What will be the output of the following program?
Note:Includes all required header files

using namespace std;
int main()
{
int find[] = {1, 2, 3, 4};
int *p = (find + 1);
cout << *find + 9;
return 0;
}

A. 9
B. 10
C. 11
D. error

View Answer


9. What will be the output of the following program?
Note:Includes all required header files

using namespace std;
int main ()
{
int find[5];
int * p;
p = find;
*p = 1;
p++; *p = 2;
p = &find[2]; *p = 3;
p = find + 3; *p = 4;
p = find; *(p + 4) = 5;
for (int n = 0; n < 5; n++)
cout << find[n] << ",";
return 0;
}

A. 1,2,3,4,5,
B. 12345
C. compile error
D. runtime error

View Answer



Discussion

* You must be logged in to add comment.