L&T INFOTECH PAPER - 08 MAR 2008

Hi Friends

This is Partho Mota from OEC. On 8th March L&T came to our college, and I was one of the lucky from 3000 std. who appeared.

some of the sample C question asked from me were as follows:-

1.What's the expected output for the following program and why?
enum {false,true};
int main()
{
int i=1;
do
{
printf("%d
",i);
i++;
if(i < 15)
continue;
}while(false);
return 0;
}

2.The following C program segfaults of IA-64, but works fine on IA-32.
int main() { int* p; p = (int*)malloc(sizeof(int)); *p = 10; return 0; }
Why does it happen so?

3.I thought the following C program is perfectly valid (after reading about the comma operator in C). But there is a mistake in the following program, can you identify it?
#include
int main()
{
int a = 1,2;
printf("a : %d
",a);
return 0;
}

4.Explain the output of the following C program (No, the output is not 20).
#include
int main() { int a=1; switch(a) { int b=20; case 1: printf("b is %d
",b); break; default:printf("b is %d
",b); break; } return 0; }


Shared by: