Amazon C++ Interview Questions

1. What is the output of the program?

main()
{
int c=5;
cout<< < <<(c<<2)<<(c>> 2);
}

a) 5 b) 7 c) 3 d) None of the above

2. What is the output of the program?

main()
{
int a[8][10],c=0,i,j;
for(i=0;i<10;i++)
for(j=0;j<8;j++)
a[j][i]=c++;
cout<< a[3][6];
}

a) 3 6 b) 8 9 c) 7 6 d) None of the above

3. Find the error in this program?

main()
{
char *p,*q;
p=(char *)malloc(25);
q=(char*) malloc(25);
strcpy(p,'amazon' );
strcpy(q,'hyd');
strcat(p,q);
cout<

}

a) amazonhyd b) amzon c) hyd d) None
4. Convert the expression into prefix and postfix notations

(a+b)*c-(d+e)^(f-g)

5. What is the output of the program?

main()
{
int i=5;
cout< }
void fun (int i)
{ if(i%2) return (i+(7*4)-(5/2)+(2*2));
else return (i+(17/5)-(34/15)+(5/2));
}

Shared by: Susant Kumar