1.
a. 0 Garbage Value 2
b. 0 1 2
c. 1 2 3
d. None of the above
2.
a. 123 456
b. 123 123
c. 456 456
d. 456 123
3.
a. Syntax Error
b. Fatal Error
c. 0 4
d. System Hangs
4.
a. Some Values
b. 0 Some Value
c. Error
c. None of the Above
5.
a. Error
b. Garbage Value 1
b. 0 1
d. 1 2
6.
a. plus
b. Compilation Error
c. Runtime Error
d. Linker Error
7.
a. 20 20
b. Garbage Value 20
c. 0 20
d. Linker Error
8.
a. 0 -200 300 10 4
b. 300 -200 300 10 4
c. -200 300 10 4 0
d. 100 -200 300 4 10
9.
a. 1
b. 0
c. No Output
d. Error
10.
a. Program Hangs
b. No Output
c. 6 4 2
d. 5 2
11.
What will be the output of the following program :
a. 1234 1234
b. 1235 1235
c. 1234 1235
d. 1235 1234
12.
What will be the output of the following program :
a. Compile-Time Error
b. 0.0 0.0 0.0 0.0 0.0
c. 0.0 0.1 0.2 0.3 0.4
d. 1.0 1.0 1.0 1.0 1.0
13.
What will be the output of the following program :
a. Compile-Time Error
b. Testing...Done
c. Testing...Done
Testing...Done
d. None of these
14.
A signed int bitfield 1-bit wide can only hold the values
a. 0 and 1
b. 0 and -1
c. 0, 1 and -1
d. None of these
15.
a. 100
b. Linker Error
c. Run Time Error
d. Compiler Error
16.
a. Compile-Time Error
b. Default1Case1
c. Default2
d. Default1
17.
a. 3 0
b. 5 3
c. 3 5
d. 5 0
18. Evaluate the following:
a. 10
b. 11
c. 1
d. 0
19. What does the line containing "break;" do in the following code?
a. Breaks out of the if statement
b. Exits the function
c. Compiler error
d. Nothing
20. What does the following code do?
a. Outputs 12
b. Outputs 10
c. Outputs the address of v
d. No Output
21. If a machine architecture assigns 4 bytes to store the address of a variable, what should be the output of the program stated below?
a. 1 4
b. 4 4
c. 4 1
d. 1 1
22. What would be the output of the following?
a. 100
b. 200
c. Compiler Error
d. None of the above
23. What would be the output of the following?
a. A
b. B
c. All the above
d. None of the above
24. What would be the output of the following?
a. 25
b. 11
c. Error
d. Garbage Value
25. If the following program(myprog) is run from the command line as myprog mon tue wed thu, what would the output?
a. myprog mon tue wed thu
b. mon tue wed thu
c. myprog tue thu
d. tue thu
26. What is the type of variable f2 and p2 in the following declaration?
#define floatptr float *
#define int * intptr
floatptr f1,f2;
intptr p1,p2;
a. float, int pointer
b. float pointer, int pointer
c. float, int
d. float pointer, int
27. What would be the output of the following?
a. 128
b. 0
c. Garbage Value
d. Error
28. If the following program(myprog) is run from the command line as myprog fri tue sun, what would the output?
a. m
b. f
c. s
d. None of the above
29. What would be the output of the following?
a. 5
b. 12
c. 10
d. 11
30. What would be the output of the following?
a. Hello
b. lo
c. llo
d. Error
31.
releases memory from a linked list. Which of the following accurately describes how it will work?
a. It will work correctly since the for loop covers the entire list.
b. It may fail since each node nptr is freed before its next address can be accessed.
c. This is invalid syntax for freeing memory
d. The loop will never end
32. In C, what is the difference between a declaration and definition of a variable?
a. Both can occur multiple times, but a declaration must occur first.
b. Both can occur multiple times, but a definition must occur first.
c. A definition occurs once, but declaration may occur many times.
d. A declaration occurs once, but definition may occur many times.
33. What would be the output of the following?
a. 22 10 11 13
b. 22 11 11 11
c. 22 10 11 13
d. 22 13 13 13
34. sizeof is an ________________
a. int
b. unsigned int
c. long int
d. Anyone of the above
35. . and -> are __________ operators.
a. Binary
b. Unary
c. Ternary
d. None of the above
36. What would be the output of the following?
a. 1234 1234
b. 1234 01234
c. 1234 668
d. 1234 688
37. chmod() function is defined in which header file?
a. assert.h
b. dos.h
c. io.h
d. Mem.h
38. The header file which includes stdarg.h is_____________
a. assert.h
b. dos.h
c. io.h
d. Mem.h
39. _______________ is a direct interface to the DOS call 0x44
a. ioctl
b. ios
c. dup
d. tell
40. What would be the output of the following?
a. 0
b. 3
c. 2
d. 1
41. What would be the output of the following?
a. old old old old
b. 7ld 8ld 7ld 8ld
c. 10ld 7ld 10ld 7ld
d. Error
42. longjmp cannot pass the value ________.
a. -1
b. 0
c. 1
d. 2
43. Scope of a global variable which is declared as __________ is within the file.
a. static
b. extern
c. register
d. function argument
44. What value is returned by abort function?
a. Depends on the parameter passed
b. 3
c. Depends on the Operating System
d. 0
45. What would be the output of the following?
a. System Hangs
b. 100 100
c. 0 100
d. 1 100
46. What would be the output of the following?
a. 5
b. 10
c. Error
d. Garbage Value
47. What would the output of the following?
a. 7 1
b. 7 -1
c. 7 0
d. 5 1
48. What would be the output of the following?
a. eMissi
b. eMissi ssippiz
c. Mississippi
d. Missi
49. Format specifier %p is used for _______________
a. Print the address contained in a pointer variable
b. Peak a value at a location
c. Print the address in segment: offset notation
d. Same as %d
50. What would be the output of the following program?
a. free() fails
b. I Love You
c. malloc() fails
d. strcpy() fails
51. What would be the output of the following?
a. 1
b. 0
c. Error
d. No output
52. What would be the output of the following?
a.
1 0 1
1 0 2
1 0 2
b.
0 1 1
1 1 1
1 1 1
c.
1 2 3
2 2 3
2 3 3
d.
1 0 1
1 0 1
1 1 2
53. What would be the output of the following?
a. 0 5 9 13 17
b. 5 9 13 17
c. 12 17 22
d. 16 21
54. What would be the output of the following?
a. 64 4
b. 27 4
c. 27 6
d. 64 6
55. What would be the output of the following?
a. 64
b. 4
c. 16
d. None of the above
56. What would be the output of the following?
a. Invalid Pragma
b. 12
c. 100
d. Compiler Error
57. What would be the output of the following?
a. 1.00
b. 0.50
c. 0.00
d. -0.50
58. Which one of the following describes the chief difference between a structure and a union?
a. The fields of a structure overlap each other in memory; the fields of a union are allocated sequentially.
b. The compiler pads structures for word alignment; the compiler allocates exactly enough space for a union to hold all of its fields.
c. A union may contain bitfields; a structure may not.
d. The fields of a structure exist concurrently; the fields of a union do not.
59. What would be the output of the following?
a. 4
b. 5
c. 6
d. None of the above
60. f = fopen( fileName, "r" );
What should replace the ???? in the code above to determine if the file could NOT be opened?
a. fclose( f )
b. f == -1
c. f != 0;
d. f == NULL
Code: C
#include<stdio.h>
#include<conio.h>
main()
{
int a[3],i;
for(i=0;i<3;i++)
a[i]=i++;
for(i=0;i<3;i++)
printf("\t%d",a[i]);
}
b. 0 1 2
c. 1 2 3
d. None of the above
2.
Code: C
void main()
{
int a = 123, b = 456;
a ^= b ^= a ^= b;
printf("%d\t%d",a,b);
}
b. 123 123
c. 456 456
d. 456 123
3.
Code: C
void main()
{
int a=5,b=4,c=10;
*((a>b) ? &a : &b) = (a+b>c);
printf("%d\t%d",a,b);
}
b. Fatal Error
c. 0 4
d. System Hangs
4.
Code: C
void f(int *ip)
{
static int dummy = 5;
ip = &dummy;
printf("%u\n",ip);
}
void main()
{
int *ip;
f(ip);
printf("%u",ip);
}
b. 0 Some Value
c. Error
c. None of the Above
5.
Code: C
void main()
{
int realarray[2]={1,2};
int *array = &realarray[-1];
int i;
for(i=0;i<2;i++)
{
printf("\t%d",*array);
array++;
}
}
b. Garbage Value 1
b. 0 1
d. 1 2
6.
Code: C
#define Str(x) #x
#define Xstr(x) Str(x)
#define OP plus
void main()
{
char *opname = Xstr(OP);
printf("%s",opname);
}
b. Compilation Error
c. Runtime Error
d. Linker Error
7.
Code: C
main()
{
extern i;
printf("%d\n",i);
{
int i=20;
printf("%d\n",i);
}
}
b. Garbage Value 20
c. 0 20
d. Linker Error
8.
Code: C
int main()
{
int a=500,b=100,c=30,d=40,e=19;
a+=b-=c*=d/=e%=5;
printf("\n%d %d %d %d %d",a,b,c,d,e);
}
b. 300 -200 300 10 4
c. -200 300 10 4 0
d. 100 -200 300 4 10
9.
Code: C
void main()
{
int a=1,b=2,c=3,d=4;
printf("%d",!a?b?!c:!d:a);
}
b. 0
c. No Output
d. Error
10.
Code: C
void main()
{
int i;
for (i=5; ++i; i-=3)
printf("%d ",i);
}
b. No Output
c. 6 4 2
d. 5 2
11.
What will be the output of the following program :
Code: C
void main()
{
int val=1234;
int* ptr=&val;
printf("%d %d",val,*ptr++);
}
b. 1235 1235
c. 1234 1235
d. 1235 1234
12.
What will be the output of the following program :
Code: C
void main()
{
int i;
float a[5];
for (i=0; i<5; i++)
a[i] = (printf, ("%d",i/10.0));
for (i=0; i<5; i++)
printf("%.1f ",a[i]);
}
b. 0.0 0.0 0.0 0.0 0.0
c. 0.0 0.1 0.2 0.3 0.4
d. 1.0 1.0 1.0 1.0 1.0
13.
What will be the output of the following program :
Code: C
void func()
{
printf("Testing...Done\n");
}
void main()
{
func;
func();
}
b. Testing...Done
c. Testing...Done
Testing...Done
d. None of these
14.
A signed int bitfield 1-bit wide can only hold the values
a. 0 and 1
b. 0 and -1
c. 0, 1 and -1
d. None of these
15.
Code: C
void main()
{
int _;
_=100;
printf("%d",_);
}
b. Linker Error
c. Run Time Error
d. Compiler Error
16.
Code: C
void main()
{
int choice=2;
switch(choice)
{
default:
printf("Default1");
case 1:
printf("Case1");
break;
default:
printf("Default2");
}
}
b. Default1Case1
c. Default2
d. Default1
17.
Code: C
#define big(a,b) a > b ? a : b
#define swap(a,b) temp=a; a=b; b=temp;
void main()
{
int a=3,b=5,temp=0;
if ((3+big(a,b)) > b)
swap(a,b);
printf("%d %d",a,b);
}
b. 5 3
c. 3 5
d. 5 0
18. Evaluate the following:
Code: C
int fn(int v)
{
if(v==1 || v==0)
return 1;
if(v%2==0)
return fn(v/2)+2;
else
return fn(v-1)+3;
}
for fn(7);
b. 11
c. 1
d. 0
19. What does the line containing "break;" do in the following code?
Code: C
void afunction()
{
if(1)
{
break;
afunction();
printf("Error");
}
}
b. Exits the function
c. Compiler error
d. Nothing
20. What does the following code do?
Code: C
void afunction(int *x)
{
x=new int;
*x=12;
}
int main()
{
int v=10;
afunction(&v);
printf(%d,v);
}
b. Outputs 10
c. Outputs the address of v
d. No Output
21. If a machine architecture assigns 4 bytes to store the address of a variable, what should be the output of the program stated below?
Code: C
main()
{
char *p;
printf(%d %d, sizeof(char *p), sizeof(*p));
}
b. 4 4
c. 4 1
d. 1 1
22. What would be the output of the following?
Code: C
main()
{
int a=10,b;
a>=5?b=100:b=200;
printf("\n%d",b);
}
b. 200
c. Compiler Error
d. None of the above
23. What would be the output of the following?
Code: C
main()
{
int i=4;
switch(i)
{
default: printf(A);
case 1: printf(B);
break;
case 2: printf(C);
break;
case 3: printf(D);
break;
}
}
b. B
c. All the above
d. None of the above
24. What would be the output of the following?
Code: C
#define SQR(x) x*x
main()
{
int a,b=3;
a=SQR(b+2);
printf(%d,a);
}
b. 11
c. Error
d. Garbage Value
25. If the following program(myprog) is run from the command line as myprog mon tue wed thu, what would the output?
Code: C
main(int argc, char *argv[])
{
while(--argc>0)
printf(%s, *++argv);
}
b. mon tue wed thu
c. myprog tue thu
d. tue thu
26. What is the type of variable f2 and p2 in the following declaration?
#define floatptr float *
#define int * intptr
floatptr f1,f2;
intptr p1,p2;
a. float, int pointer
b. float pointer, int pointer
c. float, int
d. float pointer, int
27. What would be the output of the following?
Code: C
main()
{
const int x;
x=128;
printf(%d,x);
}
b. 0
c. Garbage Value
d. Error
28. If the following program(myprog) is run from the command line as myprog fri tue sun, what would the output?
Code: C
main(int argc, char *argv[])
{
printf(%c,**++argv);
}
b. f
c. s
d. None of the above
29. What would be the output of the following?
Code: C
void main()
{
int z,x=5,y=-10,a=4,b=2;
z=x++ - --y *b/a;
printf("\n%d",z);
}
b. 12
c. 10
d. 11
30. What would be the output of the following?
Code: C
char *fun(char *ptr)
{
ptr+=3;
return(ptr);
}
void main()
{
char *x,*y;
x="Hello";
y=fun(x);
printf("\n%s",y);
}
b. lo
c. llo
d. Error
31.
Code: C
struct node *nptr,*sptr; /*pointers for linked list*/
for(nptr=sptr;nptr;nptr=nptr->next)
{
free(nptr);
}
a. It will work correctly since the for loop covers the entire list.
b. It may fail since each node nptr is freed before its next address can be accessed.
c. This is invalid syntax for freeing memory
d. The loop will never end
32. In C, what is the difference between a declaration and definition of a variable?
a. Both can occur multiple times, but a declaration must occur first.
b. Both can occur multiple times, but a definition must occur first.
c. A definition occurs once, but declaration may occur many times.
d. A declaration occurs once, but definition may occur many times.
33. What would be the output of the following?
Code: C
void main()
{
int a=10,b;
b=a++ + ++a;
printf("\n%d %d %d %d",b,a++,a,++a);
}
b. 22 11 11 11
c. 22 10 11 13
d. 22 13 13 13
34. sizeof is an ________________
a. int
b. unsigned int
c. long int
d. Anyone of the above
35. . and -> are __________ operators.
a. Binary
b. Unary
c. Ternary
d. None of the above
36. What would be the output of the following?
Code: C
main()
{
int val1=1234;
int val2=01234;
printf("%d %d",val1,val2);
}
b. 1234 01234
c. 1234 668
d. 1234 688
37. chmod() function is defined in which header file?
a. assert.h
b. dos.h
c. io.h
d. Mem.h
38. The header file which includes stdarg.h is_____________
a. assert.h
b. dos.h
c. io.h
d. Mem.h
39. _______________ is a direct interface to the DOS call 0x44
a. ioctl
b. ios
c. dup
d. tell
40. What would be the output of the following?
Code: C
main()
{
int i=strlen("Blue")+strlen("Purple")/strlen("Red")-strlen("Green");
printf("\n%d",i);
}
b. 3
c. 2
d. 1
41. What would be the output of the following?
Code: C
void main()
{
int i=7;
printf("\n%old %old %old %old",i,i++,i--,i++);
getch();
}
b. 7ld 8ld 7ld 8ld
c. 10ld 7ld 10ld 7ld
d. Error
42. longjmp cannot pass the value ________.
a. -1
b. 0
c. 1
d. 2
43. Scope of a global variable which is declared as __________ is within the file.
a. static
b. extern
c. register
d. function argument
44. What value is returned by abort function?
a. Depends on the parameter passed
b. 3
c. Depends on the Operating System
d. 0
45. What would be the output of the following?
Code: C
main()
{
int i,j;
for(i=0;;i++)
for(j=0;;j++)
if(j>100) break;
printf("%d%d",i,j);
}
b. 100 100
c. 0 100
d. 1 100
46. What would be the output of the following?
Code: C
main()
{
const int x=5;
int *ptr;
ptr=&x;
*ptr=10;
printf("%d",x);
}
b. 10
c. Error
d. Garbage Value
47. What would the output of the following?
Code: C
main()
{
int y,x=5;
y=++x - ++x;
printf("\n%d%d",x,y);
}
b. 7 -1
c. 7 0
d. 5 1
48. What would be the output of the following?
Code: C
main()
{
char *str = "\eMissi\0ssippi\z";
printf("%s",str);
}
b. eMissi ssippiz
c. Mississippi
d. Missi
49. Format specifier %p is used for _______________
a. Print the address contained in a pointer variable
b. Peak a value at a location
c. Print the address in segment: offset notation
d. Same as %d
50. What would be the output of the following program?
Code: C
main()
{
char *str,*str1="I Love You";
str=malloc(strlen(str1));
strcpy(str,str1);
printf("%s",str);
free(str);
}
b. I Love You
c. malloc() fails
d. strcpy() fails
51. What would be the output of the following?
Code: C
main()
{
char a[5][5],flag;
a[0][0] = 'A';
flag=((a==*a)&&(*a==a[0]));
printf("\n%d",flag);
}
b. 0
c. Error
d. No output
52. What would be the output of the following?
Code: C
main()
{
static int a[]={0,1,2,3,4};
static int *p[]={a,a+1,a+2,a+3,a+4};
int **ptr;
ptr=p;
**ptr++;
printf("\n%d %d %d",ptr-p,*ptr-a,**ptr);
*++*ptr;
printf("\n%d %d %d",ptr-p,*ptr-a,**ptr);
++**ptr;
printf("\n%d %d %d",ptr-p,*ptr-a,**ptr);
getch();
}
1 0 1
1 0 2
1 0 2
b.
0 1 1
1 1 1
1 1 1
c.
1 2 3
2 2 3
2 3 3
d.
1 0 1
1 0 1
1 1 2
53. What would be the output of the following?
Code: C
main()
{
int i=0;
for(i=0;i<20;i++)
{
switch(i)
{
case 0: i+=5;
case 1: i+=2;
case 5: i+=5;
default: i+=4;
break;
}
printf("\t%d",i);
}
}
b. 5 9 13 17
c. 12 17 22
d. 16 21
54. What would be the output of the following?
Code: C
#define CUBE(x) x*x*x
main()
{
int a,b=3;
a=CUBE(b++);
printf("\n%d\t%d",a,b);
}
b. 27 4
c. 27 6
d. 64 6
55. What would be the output of the following?
Code: C
#define square(b) b*b
main()
{
int a;
a=64/square(4);
printf("\n%d",a);
}
b. 4
c. 16
d. None of the above
56. What would be the output of the following?
Code: C
#define f(g,g2) g##g2
main()
{
int var12=100;
printf(%d,f(var,12));
}
b. 12
c. 100
d. Compiler Error
57. What would be the output of the following?
Code: C
main()
{
int x = 5;
int y = 10;
double z;
z = (double) (5 / 10);
printf("z = %.2f\n", z);
}
b. 0.50
c. 0.00
d. -0.50
58. Which one of the following describes the chief difference between a structure and a union?
a. The fields of a structure overlap each other in memory; the fields of a union are allocated sequentially.
b. The compiler pads structures for word alignment; the compiler allocates exactly enough space for a union to hold all of its fields.
c. A union may contain bitfields; a structure may not.
d. The fields of a structure exist concurrently; the fields of a union do not.
59. What would be the output of the following?
Code: C
int x=5;
void print()
{
printf("%d",x--);
}
main()
{
print(x++);
}
b. 5
c. 6
d. None of the above
60. f = fopen( fileName, "r" );
Code: C
if( ???? )
{
fprintf( stderr, "Could not open file!" );
exit( -1 );
}
a. fclose( f )
b. f == -1
c. f != 0;
d. f == NULL

