Company: HCL Technologies

1) Consider the following program
main()
{ int y=7;
if(y++>6 && y++!=8 && y++>7)
printf(“%dn”,y);
else
printf(“%dn”,y);
}
what is printed when this program is executed?
a] 7 b] 8 c] 9 d] 10.
2)consider the following program
main()
{ int i=4;
switch(i) {
case 1: i++;
default: i +=2;
case 2: i++;
break;
case 3: i++;
}
printf(“%dn”,i);
}
what is the value printed when the above program is executed.
a] 5 b] 6 c] 7 d] 8.
3)what is printed when this program is executed?
main()
{
printf(“%dn”,f(7));
}
f(x)
{
if (x <= 4) return x; return f(--x); } a] 4 b] 5 c] 6 d] 7. 4)on a machine where pointers are 4 bytes long, what happens when the following code is executed? main() { int x = 0, *p = 0; x++; p++; printf("%d and %dn",x,p); } a] 1and1 are printed b] 1and4 are printed c] 4and4 are printed d] causes an exception. 5)which of the following is the wrong code for strcpy,that is used to copy the contents from src to dst (a) strcpy(char *dst, char *src) { while (*src) *dst++ = *src++; } (b) strcpy(char *dst,char *src) { while(*dst++ = *src++); } Simillarly some segements for (c) and (d) were given. the choices for answers were 1] a only 2] a and b only 3] a,b and c