C++ Interview Questions - Dell

1. What is the output of the following program?
main(){
void swap();
int x = 45, y = 15;
swap(&x,&y);
cout<< “x=”<}
void swap(int *a, int *b){
*a^=*b, *b^=*a, *a^ = *b;

a) x = 15, y =45
b) x =15, y =15
c) x =45 ,y =15
d) x =45 y = 45

2. What is the output of the following program?
main(){
int i =257;
int *iptr =&i;
cout<<*((char*)iptr),*((char *)iptr+1));
}

a)1, 257 b)257 1 c)0 0 d)1 1

3. What is the output of the following program?
main(){
int i =300;
char *ptr = &i;
*++ptr=2;
cout<}

a) 556 b) 300 c) 2 d) 302

4. What is the output of the following program?

#include
main(){
char *str ="yahoo";
char *ptr =str;
char least =127;
while(*ptr++)
least = (*ptr
cout<}
a) 0 b)127 c) yahoo d) y

5. What is the output of the following program?
void main(){
int I =10, j=2;
int *ip = &I ,*jp =&j;
int k = *ip/*jp;
cout<}

a) 2
b) 5
c) 10
d) Compiler error
Post your comment