C OBJECTIVE QUESTIONS:
1)Choose the correct statement.
a)Use of Goto enhaces the logical clarity of a code
b)Use of goto makes the debugging task easier.
c)Use goto when you want to jump out of a nested loop.
d)Never use goto
b)Use of goto makes the debugging task easier.
c)Use goto when you want to jump out of a nested loop.
d)Never use goto
2)Which is true of conitional compilation?
a)It is taken care of by the compiler
b)it is setting the compiler option conditionally
c)it is compiling a program based on a condition
d)it is taken care of by the pre-processor.
b)it is setting the compiler option conditionally
c)it is compiling a program based on a condition
d)it is taken care of by the pre-processor.
3)C was primarily developed as a
a)Systems programming language
b)general purpose language
c)data processing language
d)none of the above
b)general purpose language
c)data processing language
d)none of the above
4)C is a
a)high level lanauge
b)low level language
c)high level language with some low level features
d)low level language with some high level features
b)low level language
c)high level language with some low level features
d)low level language with some high level features
5)Even if a particular implementation does not limit the
number of characters in an identifier, it is advisable to be concise because
a)chances of typographic errors are les
b)it may be processed by assembler, loaders,etc., which may have their own rules that may contradict the language rules
c)by being concise, one can be mnemonic.
d)none of the above
b)it may be processed by assembler, loaders,etc., which may have their own rules that may contradict the language rules
c)by being concise, one can be mnemonic.
d)none of the above
6)The minimum number of temporary variables needed to swap
the contents of two variables is
1)1 b)2 c)3 d)0
7)The purpose of the following program fragment
b=s+b; s=b-s;
b=b-s;
where s,b are two integers is to
a)transfer the contents of s to b
b)tansfrer the contents of b to s
c)exchange the content of s and b
d)negate the contents of s and b
b)tansfrer the contents of b to s
c)exchange the content of s and b
d)negate the contents of s and b
8)Consider the function
Find(int
x,int y)
{return ((x<y)?0Lx-y));}
Let a,b be two non-negative integers.The call
find(a,find(a,b)) can be used to find
a)maximum of a,b b)positive
difference of a,b
c)sum of a,b d)minimum of a,b
c)sum of a,b d)minimum of a,b
9)Let a,b bet non-negative integers. Which of the following
calls, finds the positive difference of a and b?
a)find(a,b) +find(b,a) b)find(a,find(a,b))
c)a+find(a,b) d)b+find(a,b)
a)find(a,b) +find(b,a) b)find(a,find(a,b))
c)a+find(a,b) d)b+find(a,b)
10)If integer needs two bytes of storage, then maximum value
of an unsigned integer is
a)2 (16)-1 b)2(15)-1 c)2(16) d)2(15)
a)2 (16)-1 b)2(15)-1 c)2(16) d)2(15)
11)printf(“%d”,printf(“tim”));
a)results in a syntax error b)outputs tim3
c)outputs garbage d)prints tim and terminates abruptly
a)results in a syntax error b)outputs tim3
c)outputs garbage d)prints tim and terminates abruptly
12)if abc is the input,then the following program fragment
Char x,y,z ;
13) Printf(“%d”,scanf(“%c%c%c”,&x,&y,&z));
results in
a)a syntax error b)a fatal error
c)segmentation vilation d)priting of 3
a)a syntax error b)a fatal error
c)segmentation vilation d)priting of 3
14)consider the statements
putchar(getchar()); putchar(getchar());
putchar(getchar()); putchar(getchar());
If a b is the input ,the output will be
a)an error message b)this can not be the input
c)ab d)a b
a)an error message b)this can not be the input
c)ab d)a b
15)Let a,b be two positive integers. Which of the following
options correctly relates / and % ?
a)b=(a/b)*b + a%b b)a=a(a/b)*b+a%b
c)b=(a%b) +a/b d)a=(a%b) + a/b
a)b=(a/b)*b + a%b b)a=a(a/b)*b+a%b
c)b=(a%b) +a/b d)a=(a%b) + a/b
16)Literal means
a)a string b)a string constant
c)a character d)an alphabet
a)a string b)a string constant
c)a character d)an alphabet
17)Length of the string “correct” is
a)7 b)8
c)6 d)implementation dependent
a)7 b)8
c)6 d)implementation dependent
18)Which of the following are true regardless of the
implementation?
a)sizeof(int) is not less than sizeof(long)
b)sizeof(short) equals sizeof(int)
c)sizeof(int) equals sizeof(unsingned)
d)sizeof(double) is not less than sizeof(float)
b)sizeof(short) equals sizeof(int)
c)sizeof(int) equals sizeof(unsingned)
d)sizeof(double) is not less than sizeof(float)
19)Coercion
a)takes place across an assignment operator
b)takes place if an operator has operands of different data types
c)means casting
d)none of the above
b)takes place if an operator has operands of different data types
c)means casting
d)none of the above
20)Choose the correct statements
a)Casting refers to implicit type conversion
b)Coercion refers to implicit type conversion
c)Casting refers to explicit type conversion
d)Coercion refers to explicit type conversion
a)Casting refers to implicit type conversion
b)Coercion refers to implicit type conversion
c)Casting refers to explicit type conversion
d)Coercion refers to explicit type conversion
21)Consider the following program fragment
char c=’a’;
while(c++<=’z’) putchar(xxx);
char c=’a’;
while(c++<=’z’) putchar(xxx);
If the required output is abcdefghijklmnopqrstuvwxyz, then
xxx should be
a)c b)C++ c)c-1 d)-c
a)c b)C++ c)c-1 d)-c
22)Which of the following comments are true ?
a)C provides no input output features
b)C provides no file access features
c)C borrowed most of its ideas from BCPL
d)C provides no features to manipulate composite objects
a)C provides no input output features
b)C provides no file access features
c)C borrowed most of its ideas from BCPL
d)C provides no features to manipulate composite objects
23)If y is of integer type then the expressions
3**y-8)/9 and (y-8)/9*3
a)must yield the same value b)must yield different values
3**y-8)/9 and (y-8)/9*3
a)must yield the same value b)must yield different values
c)may or may not yield the same value d)none of the above
24)If y is of integer type then the expression
3*(y-8)/9 and (y-8) / 9*3
yield the same value if:
3*(y-8)/9 and (y-8) / 9*3
yield the same value if:
a)y is an event number b)y
is an odd number
c)y-8 is an integral multiple of 9 d)y-8 is an integral multiple of 3
c)y-8 is an integral multiple of 9 d)y-8 is an integral multiple of 3
25)Integer division results in
a)truncation b)rounding
c)overflow d)none of the above
a)truncation b)rounding
c)overflow d)none of the above
26)Which of the following comments about EOF are true?
a)Its value is defined within stdio.h
b)its value is implementation dependent
c)its value can be negative
d)Its value should not equal the integer equivalent of any character
b)its value is implementation dependent
c)its value can be negative
d)Its value should not equal the integer equivalent of any character
27)The value of an automatic variable that is declared but
not initialized will be :
a)0 b)-1 c)unpredictable d d)one of the above
28)Choose the correct statements
a)An identifier may start with an underscore
b)An identifier may end with an underscore
c)If is a valid identifier
d)The number of significant characters in an identifier is implementation dependent
a)An identifier may start with an underscore
b)An identifier may end with an underscore
c)If is a valid identifier
d)The number of significant characters in an identifier is implementation dependent
29)The const feature can be applied to
a)an identifier b)an array
c)an array argument d)none of the above
a)an identifier b)an array
c)an array argument d)none of the above
30)Which of the following operators takes only integer
operands?
a)+ b)* c)/ d)%
31)In an expression involving || operator, evaluation
a)will be stopped if one of its components evaluates to false
b)will be stopped if one of its components evaluates to true
c)takes place from right to left
d)takes place from left to right
a)will be stopped if one of its components evaluates to false
b)will be stopped if one of its components evaluates to true
c)takes place from right to left
d)takes place from left to right
32)The statement
If(myprt!=NULL)
*myptr=NULL;
else
*myptr=NULL;
has the same effect as the statement(s);
*myptr=NULL;
else
*myptr=NULL;
has the same effect as the statement(s);
a)if(myptr) *myptr=NULL;
else *myptr=NULL;
b)*myptr=NULL;
c)if(!myptr) *myptr=NULL;
else *myptre=NULL;
d)if(myptr==NULL) *myptr=NULL;
else *myptr=NULL;
else *myptr=NULL;
b)*myptr=NULL;
c)if(!myptr) *myptr=NULL;
else *myptre=NULL;
d)if(myptr==NULL) *myptr=NULL;
else *myptr=NULL;
34)Pick the operators that associate from the left:
a)+ b), c)= d)<
35)Pick the operators that associate from the right:
a)?: b)+= c)= d)!=
36)The operators . , ||,<,=, if arranged in ascending
order of precedence reads
a)
a)
37)Pick the operators whose meaning is context dependent?
a)* b)#
c)& d)No such operator exists.
a)* b)#
c)& d)No such operator exists.
38)The following code fragment
int x,y=2,z,z;
int x,y=2,z,z;
X=(y=y*2) +(z=a=y);
Printf(“%d”,x);
a)print 8 b)prints
6
c)prints 6 or 8 depending on the compiler implementation
d)is syntactically wrong
c)prints 6 or 8 depending on the compiler implementation
d)is syntactically wrong
39)if n has the value 3 then the output of the statement
printf(“%d %d”,n++,++n);
a)is 3 5 b)is 4 5
c)is 4 4 d)is implementation dependent
a)is 3 5 b)is 4 5
c)is 4 4 d)is implementation dependent
40)x-=y+1; means
a)x=x-y+1 b)x=-x-y-1
c)x=-x+y+1 d)x=x-y-1
a)x=x-y+1 b)x=-x-y-1
c)x=-x+y+1 d)x=x-y-1
41)Which of the following comments about the ++operator are correct ?
A)It is a unary operator b)The
operand can come before or after the operator
c)It can not be applied to an expression d)It associates from the right
c)It can not be applied to an expression d)It associates from the right
42)In standard C, trigraph in the source program are
translated
a)before the lexical analysis b)after the syntax analysis
c)before the recognition of escape characters in strings d)during the intermediate code generation phase.
c)before the recognition of escape characters in strings d)during the intermediate code generation phase.
43)printf(“%c”,100;
a)prints 100 b)prints
the ASCII equivalent of 100
c)prints garbage d)none of the above
c)prints garbage d)none of the above
44)The program fragment
int i=263;
putchar(i);
a)prints 263 b)prints the ascii equivalent of 263
c)rings the bell d)prints garbage
int i=263;
putchar(i);
a)prints 263 b)prints the ascii equivalent of 263
c)rings the bell d)prints garbage
45)Which of the following comments regarding the reading
of a string ,using scanf (with %s option
) and gets , is true?
a)Both can be used interchangeably b)scanf is delimited by end of line,while gets is not
c)scanf is delimited by blank space , while gets is not d)none of the above
c)scanf is delimited by blank space , while gets is not d)none of the above
46)The following statement
printf(“%f”,9/5);
prints
a)1.8 b)1.0 c)2.0 d)none of the above
printf(“%f”,9/5);
prints
a)1.8 b)1.0 c)2.0 d)none of the above
47)Which of the following are not keywords in C ?
a)printf b)main c)IF d)none of the above
a)printf b)main c)IF d)none of the above
48)The following program fragment
Unsigned i=1; int j=-4; printf(“%u”,i+j);
Prints
a)garbage b)-3
c)an integer that changes from machine to machine
d)none of the above
c)an integer that changes from machine to machine
d)none of the above
49)The following program fragment
For(i=3;i<15;i+=13)
printf(“%d”,i);
printf(“%d”,i);
Results in
a)a syntax error b)an
execution error
c)printing of 12 d)printing of 15
c)printing of 12 d)printing of 15
50)The following program fragment
if(a=0)
printf(“a is zero”); else printf(“a is not zero”);
if(a=0)
printf(“a is zero”); else printf(“a is not zero”);
Results in the printing of
a)a is zero b)a
is not zero
c)nothing d)garbage
c)nothing d)garbage
51)A possible output of the following program fragment
for(int i=getchar();;i=getchar())
for(int i=getchar();;i=getchar())
If(i==’x’) break;
else putchar(i); is
else putchar(i); is
a)mi b)mix c)mixx d)none of the above
52)The following program fragment
int i=5;
int i=5;
Do {putchar(i+100);printf(“%d”,i--);}
while(i);
results in the printing of
a)i5h4g3f2el b)i4h3g2fle0
c)an error message d)none of the above
while(i);
results in the printing of
a)i5h4g3f2el b)i4h3g2fle0
c)an error message d)none of the above