C++ Interview questions - Birlasoft

1. What is the value returned to OS on successful completion of the program?
a) -1
b) 1
c) 0
d) Programs do not return a value.

2. Which function C++ programs must contain?
a) start()
b) system()
c) main()
d) program()

3. What is the largest value of an integer in C++?
a) 32767
b) 65536
c) 2147483647
d) INT_MAX

4. What will be the value of i?
i = 0;
j = 0;
for(j=1;j<10;j++)
i=i+1;

a) 0 b) 1 c) 3 d) 9

5. What is the output of the following program?

int a=1;
int ab=4;
int main()
{
int b=3,a=2;
cout<}

a) 3 2 4 b) 3 2 1 c) 2 3 4 d) 1 3 4

6. Which one of the following statements allocates space to hold an array of 10 integers?

a) int *ptr = (int *) calloc(10,sizeof(int));
b) int *ptr = (int *) alloc( 10*sizeof(int));
c) int *ptr = (int *) malloc( 10*sizeof(int));
d) int *ptr = (int *)calloc(10*sizeof(int));.
Post your comment