C++/Java Interview Questions - CSC

1. What is the output of the following program?
main(){
float fl = 10.5;
double dbl = 10.5
if(fl ==dbl)
cout<< “UNITED”;
else
cout<< “DIVIDE”;
}

a) Error
b) UNITED
c) DIVIDE
d) Linkage error.

2. What is the output of the following program?
main(){
static int ivar = 5;
cout<if(ivar)
main();
}

a)1 2 3 4 5
b) 5 4 3 2 1
c)5
d) Compiler error: main cannot be recursive function.

3. What is the output of the following program?
main()
{
extern int iExtern;
iExtern = 20;
cout<}

a) 2
b) 20
c) Error
d) Linker error

4. What is the output of the following program?
#define clrscr() 100
main(){
clrscr();
cout<< clrscr();
}

a)100 b)10 c)Error d)linkage error

5. What is the output of the following program?

main()
{
void vpointer;
char cHar = 'g', *cHarpointer = "microsoft";
int j = 40;
vpointer = &cHar;
cout<<*(char*)vpointer;
vpointer = &j;
cout<<*(int *)vpointer;
vpointer = cHarpointer;
cout<<(char*)vpointer +3;
}

a) m40icrosoft b) m40microsoft c) m0crosoft d) m4mii

6. What is the output of the following program?
#define FALSE -1
#define TRUE 1
#define NULL 0
main() {
if(NULL)
puts("NULL");
else if(FALSE)
puts("TRUE");
else
puts("FALSE");
}

a) NULL b) TRUE c) FALSE d) 0

7. What is the output of the following program?
main() {
int i =5,j= 6, z;
cout<}

a) 13 b) 12 c) 11 d) Error

8. What is the output of the following program?

main() {
int i ;
i = accumulator();
cout<}
accumulator(){
_AX =1000
}

a)1 b)10 c)100 d)1000

9. What is the output of the following program?
main() {
int i =0;
while(+(+i--)!= 0)
i- = i++;
cout<}

a) -1 b) 0 c) 1 d) Infinite loop

10. What is the output of the following program?
main(){
int i =3;
for(; i++=0;)
cout<}

a) 1 b) 2 c) 1 2 3 d) Error: L value required.

Post your comment