Dev

Monday 19 May 2014

C/C++ MCQS

1)
#include <stdio.h>
#define a 10
main()
{
#define a 100
printf("%d",a);
}

option
1) 10
2) 100

2)

enum colors {BLACK,BLUE=10,GREEN}
main()
{
printf("%d..%d..%d",BLACK,BLUE,GREEN);
return(1);
}

1)BLACK..BLUE..GREEN
2) 0..1..2
3)0..10..11
4)0..10..2

3)
void main()
{
char far *farther,*farthest;
printf("%d..%d",sizeof(farther),sizeof(farthest));
}

Option
1)1,1
2)4,4
3)4,2

4)
main()
{
int i=400,j=300;
printf("%d..%d");
}

1) 300,400
2) 400,300
3) garbage value

5)

main()
{
int i=1;
while (i<=5)
{
printf("%d",i);
if (i>2)
goto here;
i++;
}
}
fun()
{
here:
printf("PP");
}

Option

1)error
2) 1 2 3 PP
3)1 2 3 PP 4 PP 5 PP

Answers:

1) 2
2) 3
3) 3
4) 2
5) 1