Upload
fcmitc
View
216
Download
0
Embed Size (px)
Citation preview
8/13/2019 c lang objective type questions
1/18
1. Which of the following language is predecessor to C Programming Language?
A B BCPL C++
2. C programming language was developed by
Dennis
Ritchie Ken Thompson Bill Gates Peter Norton
3. C was developed in the year ___
1970 1972 1976 1980
4. C is a ___ language
HighLevel
Low Level Middle Level Machine Level
5. C language is available for which of the following Operating Systems?
DOS Windows UnixAll
of these
6. Which of the following symbol is used to denote a pre-processor statement?
! # ~ ;
7. Which of the following is a Scalar Data type
Float Union Array Pointer
8. Which of the following are tokens in C?
Keywords Variables ConstantsAll of
the above
9. What is the valid range of numbers for int type of data?
0 to 256-32768 to
+32767-65536 to +65536
Nospecificrange
10. Which symbol is used as a statement terminator in C?
! # ~ ;
11. Which escape character can be used to begin a new line in C?
\a \b \m \n
12. Which escape character can be used to beep from speaker in C?
\a \b \m \n
13. Character constants should be enclosed between ___
Single quotes Double quotes Both a and bNone of
these
14. String constants should be enclosed between ___
Single quotes Double quotes Both a and bNone of
these
15. Which of the following is invalid?
a abc
8/13/2019 c lang objective type questions
2/18
16. The maximum length of a variable in C is ___
8 16 32 64
17. What will be the maximum size of a float variable?
1 byte 2 bytes 4 bytes 8 bytes
18. What will be the maximum size of a double variable?
1 byte 4 bytes 8 bytes 16 bytes
19. A declaration float a,b; occupies ___ of memory
1 byte 4 bytes 8 bytes 16 bytes
20. The size of a String variable is
1 byte 8 bytes 16 bytes None of these
1. Which of the following is an example of compounded assignment statement?
a = 5 a += 5 a = b = c a = b
2. The operator && is an example for ___ operator.
Assignment Increment Logical Rational
3. The operator & is used for
Bitwise AND Bitwise OR Logical AND Logical OR
4. The operator / can be applied to
integer values float values double values All of these
5. The equality operator is represented by
:= .EQ. = ==
6. Operators have hierarchy. It is used to know which operator
is most
importantis used first is faster
operates on
large numbers
7. The bitwise AND operator is used for
Masking Comparison Division Shifting bits
8. The bitwise OR operator is used to
set the desired
bits to 1
set the desired
bits to 0divide numbers multiply numbers
9. Which of the following operator has the highest precedence?
* == => +
10. The associativity of ! operator is
Right
to LeftLeft to Right
(a) for Arithmetic and
(b) for Relational
(a) for Relational and (b)
for Arithmetic
11. Which operator has the lowest priority?
++ % + ||
12. Which operator has the highest priority?
8/13/2019 c lang objective type questions
3/18
++ % + ||
13. Operators have precedence. A Precedence determines which operator is
fastertakes less
memoryevaluated first takes no arguments
14. Integer Division results in
Rounding
the fractionalpart
truncating thefractional part
Floating valueAn Error is
generated
15. Which of the following is a ternary operator?
? * sizeof ^
16. What will be the output of the expression 11 ^ 5?
5 6 11 None of these
17. The type cast operator is
(type) cast() // " "
18. Explicit type conversion is known as
Casting Conversion Disjunction Separation
19. The operator + in a+=4 means
a = a + 4 a + 4 = a a = 4 a = 4 + 4
20. p++ executes faster than p+1 because
p uses registersp++ is a single
instruction++ is faster than + None of these
1. Which of the following statements is true?
C Libraryfunctions provideI/O facilities
C inherent I/O
facilities
C doesnt have I/O
facilitiesBoth (a) and (c)
2. Header files in C contain
Compilercommands
Library functionsHeader
information of C
programs
Operators forfiles
3. Which pair of functions below are used for single character I/O.
Getchar() andputchar() Scanf() andprintf() Input() andoutput() None of these
4. The printf() function retunes which value when an error occurs?
Positive
valueZero Negative value None of these
5. Identify the wrong statement
putchar(65) putchar('x') putchar("x") putchar('\n')
8/13/2019 c lang objective type questions
4/18
6. Which of the following is charecter oriented console I/O function?
getchar()and putchar()
gets() andputs()
scanf() and printf() fgets() and fputs()
7. The output of printf("%u", -1) is
-1 minimum intvalue
maxium int value Error message
8. An Ampersand before the name of a variable denotes
Actual ValueVariable
NameAddress
DataType
9. Symbolic constants can be defined using
# define const symbolsNone
of these
10. Null character is represented by
\n \0 \o \e11. Which header file is essential for using strcmp() function?
string.h strings.h text.h strcmp.h
12. malloc() function used in dynamic allocation is available in which header file?
stdio.h stdlib.h conio.h mem.h
13. File manipulation functions in C are available in which header file?
streams.h stdio.h stdlib.h files.h
14. C supports how many basic looping constructs
2 3 4 615. A statement differs from expression by terminating with a
; : NULL .
16. What should be the expression return value for a do-while to terminate
1 0 -1 NULL
17. Which among the following is a unconditional control structure
do-while if-else goto for
18. continue statement is used
to go to the nextiteration in a loop
come out of aloop
exit and returnto the mainfunction
restartsiterations frombeginning of loop
19. Which operator in C is called a ternary operator
if..then ++ ? ()
20. Which of the following header file is required for strcpy() function?
string.h strings.h files.h strcpy()
1. The meaning of conversion character for data input is
8/13/2019 c lang objective type questions
5/18
Data item is a
long integer
Data item is an
unsigned decimalinteger
Data item is a
short integerNone of the above
2. The conversion characters for data input means that the data item is
An unsigned decimalinteger
A short integerA
hexadecimal
integer
A string followed bywhite space
3. An expression contains relational, assign. ment and arithmetic operators. If Parenthesisare not present, the order will be
Assignment,
arithmetic, relational
Relational,
arithmetic,
assignment
Assignment,
relational, arithmetic
Arithmetic, relational,
assignment
4. Which of the following is a key word is used for a storage class
printf external auto scanf
5. In the C language 'a represents
a digit an integer a character a word
6. The number of the relational operators in the C language is
Four Six Three One
7. A compound statement is a group of statements included between a pair of
double quote curly braces parenthesis a pair of /s
8. A Link is
a compileran active
debugger
a C interpretera analyzing tool
in C9. The continue command cannot be used with
for switch do while
10. In C, a Union is
memory location memory store memory screen None of these
11. When the main function is called, it is called with the arguments
argc argv None of these both a & b
12. A multidimensional array can be expressed in terms of
array of pointersrather than as pointersto a group ofcontiguous array
array without thegroup of contiguous
array
data type arrays None of these
13. C allows arrays of greater than two dimensions, who will determined this
programmer compiler parameter None of these
14. A pointer to a pointer in a form of
multipleindirection
a chain ofpointers
both a and b None of these
8/13/2019 c lang objective type questions
6/18
15. Pointers are of
integer datatype
character datatype
unsigned integerdata types
None of these
16. Maximum number of elements in the array declaration int a[5][8] is
28 32 35 4017. If the size of the array is less than the number of initializers then,
Extra values are
being ignored
Generates an
error message
Size of Array is
increased
Size is neglected
when values are given
18. Array subscripts in C always start at
-1 1 0Value provided by
user
19. A Structure
can be read as a
single entity
cannot be read as
a single entity
can be displayed
as a single entity
has member
variables that cannotbe read individually
20. Identify the invalid pointer arithmetic
Addition of float
value to a pointer
Comparision of
pointers that do notpoint to the element
of the same array
Subtracting an
integer from a pointer
Assigning thevalue 0 to a pointer
variable
Q1. What will be the output of the following arithmetic expression ?
5+3*2%10-8*6
a) -37 b) -42 c) -32 d) -28
Q2. What will be the output of the following statement ?
int a=10; printf("%d &i",a,10);a) error b) 10 c) 10 10 d) none of these
Q3. What will be the output of the following statement ?
printf("%X%x%ci%x",11,10,'s',12);
a) error b) basc c) Bas94c d) none of these
Q4. What will be the output of the following statements ?
int a = 4, b = 7,c; c = a = = b; printf("%i",c);
a) 0 b) error c) 1 d) garbage value
Q 5. What will be the output of the following statements?
int a = 5, b = 2, c = 10, i = a>b
void main(){ printf("hello"); main(); }
a) 1 b) 2 c) infinite number of times d) none of these
Q7. What will be the output of the following statements?
int x[4] = {1,2,3}; printf("%d %d %D",x[3],x[2],x[1]);
a) 03%D b) 000 c) 032 d) 321
Q8. What will be the output of the following statement?
printf( 3 + "goodbye");
a) goodbye b) odbye c) bye d) dbye
8/13/2019 c lang objective type questions
7/18
Q9. What will be the output of the following statements?
long int a = scanf("%ld%ld",&a,&a); printf("%ld",a);
a) error
b) garbage value
c) 0
d) 2
Q10. What will be the output of the following program ?
#include
void main()
{ int a = 2;
switch(a)
{ case 1:
printf("goodbye"); break;
case 2:
continue;
case 3:
printf("bye");
}
}
a) error b) goodbye c) bye d) byegoodbye
Q11. What will be the output of the following statements ?
int i = 1,j; j=i--- -2; printf("%d",j);
a) error b) 2 c) 3 d) -3
Q12. What will be the output of following program ?
#include
main()
{
int x,y = 10;
x = y * NULL;
printf("%d",x);
}
a) error b) 0 c) 10 d) garbage value
Q13. What will be the output of following statements ?
char x[ ] = "hello hi"; printf("%d%d",sizeof(*x),sizeof(x));
a) 88 b) 18 c) 29 d) 19
Q14. What will be the output of the following statements?
int a=5,b=6,c=9,d; d=(ac?1:2):(c>b?6:8)); printf("%d",d);
a) 1 b) 2 c) 6 d) 8
Q15. What will be the output of the following statements ?
int i = 3;
printf("%d%d",i,i++);
a) 34 b) 43 c) 44 d) 33
Q16. What will be the output of the following program ?
#include
8/13/2019 c lang objective type questions
8/18
void main()
{
int a = 36, b = 9;
printf("%d",a>>a/b-2);
}
a) 9 b) 7 c) 5 d) none of these
Q17)
int testarray[3][2][2] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
What value does testarray[2][1][0] in the sample code above contain?
a) 11b) 7c) 5d) 9
Q18)
void main()
{
int a=10,b=20;
char x=1,y=0;
if(a,b,x,y)
{
printf("EXAM");
}
}
What is the output?
1) XAM is printed 2) exam is printed 3) Compiler Error 4) Nothing is printed
Q19)
What is the output of the following code?
#include
void main()
{
int s=0;
while(s++
# define a 10
main()
{
printf("%d..",a);
foo();
printf("%d",a);
}
void foo()
{
#undef a
#define a 50
}
8/13/2019 c lang objective type questions
9/18
1) 10..10 2) 10..50 3) Error 4) 0
Q21)
main()
{
struct
{
int i;
}xyz;
(*xyz)->i=10;
printf("%d",xyz.i);
}
What is the output of this program?
1) program will not compile 2) 10 3) god only knows 4) address of I
Q22)
What would be the output of the following program?
#include
main()
{
char str[]="S\065AB";
printf("\n%d", sizeof(str));
}
1) 7 2) 6 3) 5 4) error
Q23)
What will be the value of `a` after the following code is executed
#define square(x) x*x
a = square(2+3)
1) 25 2) 13 3) 11 4) 10
Q24)
#include
void func()
{
int x = 0;
static int y = 0;
x++; y++;
printf( "%d -- %d\n", x, y );
}
8/13/2019 c lang objective type questions
10/18
int main()
{
func();
func();
return 0;
}
What will the code above print when it is executed?
1)
1 -- 1
1 -- 1
2)
1 -- 1
2 -- 1
3)1 -- 1
2 -- 2
4)
1 -- 1
1 -- 2
Q25)
long factorial (long x){
????
return x * factorial(x - 1);
}
With what do you replace the ???? to make the function shown above return the correct answer?
1) if (x == 0) return 0;
2) return 1;
3) if (x >= 2) return 2;
4) if (x
8/13/2019 c lang objective type questions
11/18
int i = 4;
switch (i)
{
default: ;
case 3:
i += 5;
if ( i == 8)
{
i++;
if (i == 9) break;
i *= 2;
}
i -= 4;
break;
case 8:
i += 5;
break;
}
printf("i = %d\n", i);
What will the output of the sample code above be?
1) i = 5 2) i = 8 3) i = 9 4) i = 10
1 What is the output of:main( )
{
floata = 5, b = 2 ;
intc ;
c = a % b ;
printf( "%d", c ) ;
}
A. 1
B. 0
C. 2
D. Compile Time Error
2 Find the output of the following program?
#includevoidmain( )
{
printf( "nn \n\n nn\n") ;
printf( "nn /n/n nn/n") ;
}
A. nn
nn
nn /n/n nn/n
8/13/2019 c lang objective type questions
12/18
B. nn
nn
nn /n
nn/n
C. nn
nn
nn /n
nn
D. Error "/n" not recognized
3 What is the output of the following programs:Program 1:
#include
voidmain()
{
printf("%d %d %d %d ",65,065,0x65,0X65);
}
Program 2:
#include
voidmain()
{
printf("%d %o %x",65,65,65);
}
A. 65 65 65 65 and 65 53 101
B. Compiler Error, Compiler Error
C. 65 53 101 101 and 65 101 41
D. None of the Above
1 Identify which are declarations? (select 2)
A. double pow(double,double);
B. float squar(float a){}
C. float b;
D. extern int a;
2 One c program is written in 2 files/*Program1.c*/
intx=10
/*Program2.c*/#include "Program1.c"
intmain()
{
externintx;
printf("x : %d",x);
}
In Program2.c statement extern int x; is not needed.
A. True
8/13/2019 c lang objective type questions
13/18
B. False
3 A function can have several declaration, but only one definition?
A. True
B. False
4 Which of the following is the correct output of the program?#include
intmain()
{
inta[5]={9,10};
printf("%d,%d",a[1],a[2]);
return0;
}
A. 9, 10
B. 10, 0
C. 0, 0
D. 0, 9
5 What is the output of following program?#include
intmain()
{
void*ptr1, *ptr2, x;
inty;
x = 100;
y = 200;
ptr1 = &x;
ptr2 = &y;
printf("%d", *ptr1);
pritnf("%d", *ptr2);
return0;
}
A. error: variable or field x declared void
B. 100,200
C. garbage value , 200
D. None of above
6 Guess the Output.#include
intmain()
{
enumstatus { pass, fail, atkt};
enumstatus stud1, stud2, stud3;
stud1 = pass;
stud2 = atkt;
stud3 = fail;
printf("%d, %d, %d\n", stud1, stud2, stud3);
return0;
}
8/13/2019 c lang objective type questions
14/18
A. 0, 1, 2
B. 1, 2, 3
C. 0, 2, 1
D. 1, 3, 2
7 Which of the following declarations are correct?
A. short i=10;
B. static i=10;
C. unsigned i=10;
D. const i=10;
1
What is the output of the following program?#includevoidmain()
{
inta=8,b=4;
intc,d;
c= a>6;
d= a>2 && b==3;
printf("c = %d, d= %d",c,d);
}
A. c= 1, d= 0
B. c= 0, d= 0
C.c= 0, d= 1
D. Compilation Error
2 What is the output of the following program?#include
voidmain()
{
inti=10;
switch(i)
{
case1: printf(" i=1");
break;
case10: printf(" i=10");
case11: printf(" i=11");
break;case12: printf(" i=12");
}
}
A. i=10 i=11 i=12
B. i=1 i=10 i=11 i=12
C. i=10 i=11
D. None of the Above
3 What is the output of the following program?
8/13/2019 c lang objective type questions
15/18
#include
voidmain()
{
charc = 'c';
switch(c)
{
case'a': printf("inside case a,");
break;case'b': printf("inside case b,");
break;
case'c': printf("inside case c,");
case'd': printf("inside case d,");
continue;
default: printf("inside default case");
break;
}
}
A. inside case c, inside case d
B. inside case c
C. inside case c, inside case d, inside default case
D. Compilation Error
4 What is the output of the following program?#include
voidmain()
{
charc= 'a';
switch(c)
{
case65 : printf("inside case A,");
break;
case97 : printf("inside case a,");
break;default: printf("inside default case");
break;
}
}
A. inside default case
B. inside case a,
C. Compilation Error
D. inside case A,
5 What is the output of the following program?#include
voidmain()
{
inta=8,b=4;
intc;
c=(a
8/13/2019 c lang objective type questions
16/18
C. c= 0, b= 4
D. Compilation Error
6 What is the output of the following program?#include
voidmain()
{inta=8,b=4,c;
c= ((a=50)
y=15;
printf("x=%d, y=%d , !x=%d, !z=%d", x,y,!x,!z);
}
A. =10, y=15, !x=10, !z=1
B. x=10, y=5, !x=1, !z=0
C. x=10, y=5, !x=0, !z=1
D. Compilation Error
8 What is the output of the following program?#include
voidmain()
{
inta=1,b=20;
if(a && b>5 > 25)
printf("Yo!");
else
printf("Baby!");
}
A. Yo!
B. Baby!
C. Compilation Error
D. Run Time Error
9 What is the output of the following program?#include
voidmain()
{
inti=1,j=1;
while(++i < 10)
printf("%d ",i);
8/13/2019 c lang objective type questions
17/18
printf("\n");
while(j++ < 10)
printf("%d ",j);
}
A. 1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
B. 1 2 3 4 5 6 7 8 91 2 3 4 5 6 7 8 9 10
C. 2 3 4 5 6 7 8 9
2 3 4 5 6 7 8 9 10
D. 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10
10 What is the output of the following program?#include
voidmain(){
inti=1;
switch(i
8/13/2019 c lang objective type questions
18/18
#include
voidmain()
{
intx=1;
switch(x)
{
casex: printf("case 1"); break;
case2: printf("case 2"); break;case3: printf("case 3"); break;
case4: printf("case 4"); break;
}
}
A. case 1
B. case 1
case 2
case 3
case 4
C. Compile Time Error
D. None of the Above