computer programming “c language”

37
Ans: 1 Computer Programming “C language” 1. Which of the following language is predecessor to C Programming Language? a) A b) B c) BCPL d) C++ Ans: c 2. C programming language was developed by a) Dennis Ritchie b) Ken Thompson c) Bill Gates d) Peter Norton Ans: a 3. C was developed in the year ___ a) 1970 b) 1972 c) 1976 d) 1980 Ans: b 4. C is a ___ language a) High Level b) Low Level c) Middle Level d) Machine Level Ans: c 5. C language is available for which of the following Operating Systems? a) DOS b) Windows c) Unix d) All of these Ans: d 6. Which of the following symbol is used to denote a pre-processor statement? a) ! b) # c) ~ d) ; Ans: b 7. Which of the following is a Scalar Data type a) Float b) Union c) Array d) Pointer

Upload: others

Post on 12-Apr-2022

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computer Programming “C language”

Ans:

1

Computer Programming “C language”

1. Which of the following language is predecessor to C Programming Language?

a) A

b) B

c) BCPL

d) C++

Ans: c

2. C programming language was developed by

a) Dennis Ritchie

b) Ken Thompson

c) Bill Gates

d) Peter Norton

Ans: a

3. C was developed in the year ___

a) 1970

b) 1972

c) 1976

d) 1980

Ans: b

4. C is a ___ language

a) High Level

b) Low Level

c) Middle Level

d) Machine Level

Ans: c

5. C language is available for which of the following Operating Systems?

a) DOS

b) Windows

c) Unix

d) All of these

Ans: d

6. Which of the following symbol is used to denote a pre-processor statement? a)

!

b) #

c) ~

d) ;

Ans: b

7. Which of the following is a Scalar Data type

a) Float b) Union

c) Array d) Pointer

Page 2: Computer Programming “C language”

Ans:

2

Ans: a

8. Which of the following are tokens in C?

a) Keywords b) Variables

c) Constants d) All of the above d

9. What is the valid range of numbers for int type of data?

a) 0 to 256

b) -32768 to +32767

c) -65536 to +65536

d) No specific range

Ans: b

10. Which symbol is used as a statement terminator in C?

a) !

b) #

c) ~

d) ; Ans: d

11. Which escape character can be used to begin a new line in C?

a) \a

b) \b

c) \m

d) \n

Ans: d

12. Which escape character can be used to beep from speaker in C? a)

\a

b) \b

c) \m

d) \n

Ans: a

13. Character constants should be enclosed between ___

a) Single quotes

b) Double quotes

c) Both a and b d) None of these

Ans: a

14. String constants should be enclosed between ___

a) Single quotes

b) Double quotes

c) Both a and b

d) None of these

Ans: b

Page 3: Computer Programming “C language”

Ans: b

3

15. Which of the following is invalid?

a) ‘’ b) ““

c) ‘a’ d) ‘abc’

Ans: d

16. The maximum length of a variable in C is ___

a) 8 b) 16

c) 32 d) 64 a

17. What will be the maximum size of a float variable?

a) 1 byte

b) 2 bytes

c) 4 bytes

d) 8 bytes

Ans: c

18. What will be the maximum size of a double variable?

a) 1 byte

b) 4 bytes

c) 8 bytes

d) 16 bytes

Ans: c

19. A declaration float a,b; occupies ___ of memory

a) 1 byte

b) 4 bytes

c) 8 bytes

d) 16 bytes

Ans: c

20. The size of a String variable is

a) 1 byte

b) 8 bytes

c) 16 bytes

d) None of these

Ans: d

21. Which of the following is an example of compounded assignment statement?

a) a=5

b) a+=5

c) a=b=c

d) a=b

Ans: b

22. The operator && is an example for ___ operator.

a) Assignment

b) Increment

c) Logical

Page 4: Computer Programming “C language”

Ans:

4

d) Rational

Ans: c

23. The operator & is used for

a) Bitwise AND

b) Bitwise OR

c) Logical AND

d) Logical OR

Ans: a

24. The operator / can be applied to

a) integer values b) float values

c) double values d) All of these

25. The equality operator is represented by

a) :=

b) .EQ.

c) =

d) ==

Ans: d

26. Operators have hierarchy. It is useful to know which operator

a) is most important

b) is used first

c) is faster

d) operates on large numbers

Ans: b

27. The bitwise AND operator is used for

a) Masking

b) Comparison

c) Division

d) Shifting bits

Ans: a

28. The bitwise OR operator is used to

a) set the desired bits to 1

b) set the desired bits to 0

c) divide numbers

d) multiply numbers

Ans: a

29. Which of the following operator has the highest precedence?

a) *

b) ==

c) =>

Page 5: Computer Programming “C language”

Ans: b

5

d) + Ans: d

30. The associativity of ! operator is

a) Right to Left

b) Left to Right

c) (a) for Arithmetic and (b) for Relational

d) (a) for Relational and (b) for Arithmetic

Ans: a

31. Which operator has the lowest priority?

a) ++ b) %

c) + d) ||

Ans: d

32. Which operator has the highest priority?

a) ++ b) %

c) + d) || a

33. Operators have precedence. Precedence determines which operator is a)

faster

b) takes less memory

c) evaluated first

d) takes no arguments

Ans: c

34. Integer Division results in

a) Rounding the fractional part

b) Truncating the fractional part

c) Floating value

d) An Error is generated

Ans: b

35. Which of the following is a ternary operator?

a) ?:

b) *

c) sizeof

d) ^

Ans: a

36. What will be the output of the expression 11 ^ 5?

a) 5

b) 6

c) 11

d) None of these

Ans: d

37. The type cast operator is

a) (type)

Page 6: Computer Programming “C language”

Ans:

6

b) cast()

c) (;;)

d) // " "

Ans: a

38. Explicit type conversion is known as

a) Casting

b) Conversion

c) Disjunction

d) Separation

Ans: a

39. The operator + in a+=4 means

a) a=a+4

b) a+4=a

c) a=4

d) a=4+4

Ans: a

40. p++ executes faster than p+1 because

a) p uses registers b) p++ is a single instruction

c) ++ is faster than + d) None of these

41. Which of the following statements is true?

a) C Library functions provide I/O facilities

b) C inherent I/O facilities

c) C doesn’t have I/O facilities

d) Both (a) and (c)

Ans: a

42. Header files in C contain

a) Compiler commands

b) Library functions

c) Header information of C programs

d) Operators for files

Ans: b

43. Which pair of functions below are used for single character I/O.

a) Getchar() and putchar()

b) Scanf() and printf()

c) Input() and output()

d) None of these

Ans: a

44. The printf() function retunes which value when an error occurs?

a) Positive value

Page 7: Computer Programming “C language”

Ans: b

7

b) Zero

c) Negative value

d) None of these

Ans: c

45. Identify the wrong statement

a) putchar(65)

b) putchar('x')

c) putchar("x")

d) putchar('\n')

Ans: c

46. Which of the following is charecter oriented console I/O function?

a) getchar() and putchar()

b) gets() and puts()

c) scanf() and printf()

d) fgets() and fputs()

Ans: a

47. The output of printf("%u", -1) is

a) -1 b) minimum int value

c) maxium int value d) Error message

Ans: c

48. An Ampersand before the name of a variable denotes

a) Actual Value b) Variable Name

c) Address d) Data Type c

49. Symbolic constants can be defined using

a) # define

b) const

c) symbols

d) None of these

Ans: b

50. Null character is represented by

a) \n

b) \0

c) \o

d) \e

Ans: b

51. Which header file is essential for using strcmp() function?

a) string.h

b) strings.h

c) text.h

d) strcmp.h

Ans: a

Page 8: Computer Programming “C language”

Ans:

8

52. malloc() function used in dynamic allocation is available in which header file?

a) stdio.h

b) stdlib.h

c) conio.h

d) mem.h

Ans: b

53. File manipulation functions in C are available in which header file?

a) streams.h

b) stdio.h

c) stdlib.h

d) files.h

Ans: d

54. C supports how many basic looping constructs

a) 2

b) 3

c) 4

d) 6

Ans: b

55. A statement differs from expression by terminating with a a)

;

b) :

c) NULL

d) .

Ans: a

56. What should be the expression return value for a do-while to terminate

a) 1 b) 0

c) -1 d) NULL

Page 9: Computer Programming “C language”

9

57. Which among the following is a unconditional control structure

a) do-while

b) if-else

c) goto

d) for Ans: c

58. Continue statement is used

a) to go to the next iteration in a loop

b) come out of a loop

c) exit and return to the main function

d) restarts iterations from beginning of loop

Ans: a

59. Which operator in C is called a ternary operator

a) if..then

b) ++

c) ?:

d) ()

Ans: c

60. Which of the following header file is required for strcpy() function? a)

string.h

b) strings.h

c) files.h

d) strcsspy()

Ans: a

61. The meaning of conversion character for data input is

a) Data item is a long integer

b) Data item is an unsigned decimal integer

c) Data item is a short integer

d) None of the above

Ans: c

62. The conversion characters for data input means that the data item is

a) An unsigned decimal integer

b) A short integer

c) A hexadecimal integer

d) A string followed by white space

Ans: b

63. An expression contains relational, assign. ment and arithmetic operators. If

Parenthesis are not present, the order will be

a) Assignment, arithmetic, relational b) Relational, arithmetic, assignment

c) Assignment, relational, arithmetic d) Arithmetic, relational, assignment Ans:

d

Page 10: Computer Programming “C language”

10

64. Which of the following is a key word is used for a storage class

a) printf b) external

c) auto d) scanf

Ans: c

65. In the C language 'a’ represents

a) a digit

b) an integer

c) a character

d) a word

Ans: c

66. The number of the relational operators in the C language is

a) Four

b) Six

c) Three

d) One

Ans: b

67. A compound statement is a group of statements included between a pair of

a) double quote

b) curly braces

c) parenthesis

d) a pair of /’s

Ans: a

68. A Link is a)

a compiler

b) an active debugger

c) a C interpreter

d) a analyzing tool in C

Ans: d

69. The continue command cannot be used with

a) for

b) switch

c) do

d) while

Ans: a

70. In C, a Union is

a) memory location b) memory store

c) memory screen d) None of these

Ans: b

71. When the main function is called, it is called with the arguments

a) argc b) argv

Page 11: Computer Programming “C language”

11

c) None of these d) both a & b

Ans: d

72. A multidimensional array can be expressed in terms of

a) array of pointers rather than as pointers to a group of contiguous array

b) array without the group of contiguous array

c) data type arrays

d) None of these

Ans: a

73. C allows arrays of greater than two dimensions, who will determined this

a) programmer

b) compiler

c) parameter

d) None of these

Ans: b

74. A pointer to a pointer in a form of

a) multiple indirection

b) a chain of pointers

c) both a and b

d) None of these

Ans: c

75. Pointers are of

a) integer data type

b) character data type

c) unsigned integer data types

d) None of these

Ans: d

76. Maximum number of elements in the array declaration int a[5][8] is a)

28

b) 32

c) 35

d) 40 Ans: d

77. If the size of the array is less than the number of initializers then,

a) Extra values are being ignored

b) Generates an error message

c) Size of Array is increased

d) Size is neglected when values are given

Ans: a

78. Array subscripts in C always start at

a) -1

Page 12: Computer Programming “C language”

12

b) 1

c) 0

d) Value provided by user

Ans: c

79. A Structure

a) can be read as a single entity

b) cannot be read as a single entity

c) can be displayed as a single entity

d) has member variables that cannot be read individually

Ans: b

80. Which is the correct way to declare a pointer?

a) int_ptr; b) int *ptr;

c) *int ptr; d) None of these.

Ans: b

81. If you want to exchange two rows in a two dimensional array, the fastest way is to:

a) Exchange the elements of the 2rows

b) Exchange the address of each element in the two row

c) Silence the address of the rows in an array of pointer and exchange the pointer d) None of these.

Ans: c

82. A type cast is used to

a) Define a new data type

b) Force a value to be a particular variable type

c) Rename an old type

d) None of these.

Ans: b

83. Operator precedence determines which operator

a) Operators on the largest number

b) Is used first

c) Is most important

d) None of these.

Ans:b

84. If you don’t initialize a static array, what will be the element set to? a)

Zero

b) A floating point

c) An undetermined value

d) None of these.

Ans: a

85. Which is more appropriate for reading in a multi-word string? a)

gets( )

b) Printf( )

c) scanf( )

Page 13: Computer Programming “C language”

13

d) puts ( ).

Ans: a

86. The process of translating a source program into machine language is a function of:

a) Compiler b) Translator

c) Assembler d) None of these.

Ans: a

87. Function argument can be

a) A structure member b) A pointer variable

c) A complete structure d) All of the above.

Ans: d

88. A “switch” statement is used to:

a) Switch between user defined functions in a program

b) Switch from one variable to another variable

c) Jump from one place to another in a program.

d) None of these. Ans: d

89. Consider the foll statement: "using C language programmers can write their own library functions". a)

True

b) False

c) May be

d) None of these.

Ans: a

90. C is a ________ level programming language?

a) Low

b) High

c) Middle

d) None of these.

Ans: c

91. A function is a subroutine that may include one or more ____________ designed to perform a specific task.

a) Functions

b) Statements

c) Libraries

d) Data types.

Ans:b

92. What is used as a terminator in C?

a) ?

b) ;

c) :

d) _

Ans:b

Page 14: Computer Programming “C language”

14

93. Which function is necessary to exist in each & every program? a)

void

b) sum

c) main

d) None of these.

Ans: c

94. What is the answer of: 7%3

a) 2.5

b) 1

c) 2

d) 3

Ans: b

95. The _______ chars have values from -128 to 127.

a) signed b) unsigned

c) long d) none

Ans: a

96. What is the control character for "a single character".

a) %c b) %d

c) %i d) %p

Ans: a

97. What is the control character for "a decimal integer". a)

%c

b) %d

c) %i

d) %p Ans: b

98. What is the control character for "a floating point number". a)

%c

b) %d

c) %i

d) %f

Ans: d

99. C supports the ______ statement to branch unconditionally from one point to another in the program. a)

continue

b) goto

c) break

d) for

Ans: b

100. The _______ is used to break out of the case statements. a)

continue

b) break

Page 15: Computer Programming “C language”

15

c) default

d) case

Ans: b

C Programming Multiple Choice Questions :-

1. What will be the output of the following arithmetic expression ? 5+3*2%10-8*6 a) -37 b) -42 c) -32 d) -28 Ans: a

2. 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 Ans: d

3. 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 Ans: b

4. 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 Ans: a

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 Ans: c

Page 16: Computer Programming “C language”

16

6. What will be output if you will compile and execute the following c code? struct marks{ int p:3; int c:3; int m:2; }; void main(){ struct marks s={2,-6,5}; printf(“%d %d %d”,s.p,s.c,s.m); } (a) 2 -6 5 (b) 2 -6 1 (c) 2 2 1 (d) Compiler error (e) None of these Ans: c

7. 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 Ans: c

8. What will be the output of the following statement ? printf( 3 + “goodbye”); a) goodbye b) odbye c) bye d) dbye Ans: d

9. 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 Ans: b

10. 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:

Page 17: Computer Programming “C language”

17

printf(“bye”); } } a) error b) goodbye c) bye d) byegoodbye Ans: a

11. 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 Ans: c

12. 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 Ans: b

13. 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 Ans: d

14. 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) Error Ans: d

15. What will be the output of the following statements ? int i = 3;

Page 18: Computer Programming “C language”

18

printf(“%d%d”,i,i++); a) 34 b) 43 c) 44 d) 33 Ans: b

16. What will be the output of the following program ? #include void main() { int a = 36, b = 9; printf(“%d”,a>>a/b-2); } a) 9 b) 7 c) 5 d) none of these Ans: a

17. 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) 11 b) 7 c) 5 d) 9 Ans: a

18. void main() { int a=10,b=20; char x=1,y=0; if(a,b,x,y) { printf(“EXAM”); } } What is the output? a) XAM is printed b) exam is printed c) Compiler Error d) Nothing is printed Ans: d

19. What is the output of the following code? #include void main() { int s=0; while(s++<10)> # define a 10

Page 19: Computer Programming “C language”

19

main() { printf(“%d..”,a); foo(); printf(“%d”,a); } void foo() { #undef a #define a 50 } a) 10..10 b) 10..50 c) Error d) 0 Ans: c

20. main() { struct { int i; }xyz; (*xyz)->i=10; printf(“%d”,xyz.i); } What is the output of this program? a) program will not compile b) 10 c) god only knows d) address of I Ans: b

21.What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array? A. The element will be set to 0. B. The compiler would report an error. C. The program may crash if some important data gets overwritten. D. The array size would appropriately grow. Ans: C

22. What would be the output of the following program? #include main() { char str[]=”S\065AB”; printf(“n%d”, sizeof(str)); } a) 7

Page 20: Computer Programming “C language”

20

b) 6 c) 5 d) error Ans: b

23. What will be the value of `a` after the following code is executed #define square(x) x*x a = square(2+3) a) 25 b) 13 c) 11 d) 10 Ans: c

24. #include void func() { int x = 0; static int y = 0; x++; y++; printf( “%d — %dn”, x, y ); } int main() { func(); func(); return 0; } What will the code above print when it is executed? a) 1 — 1 1 — 1 b) 1 — 1 2 — 1 c) 1 — 1 2 — 2 d) 1 — 1 1 — 2 Ans: d

25. 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? a)

Page 21: Computer Programming “C language”

21

if (x == 0) return 0; b) return 1; c) if (x >= 2) return 2; d) if (x <= 1) return 1; Ans: d

26. int y[4] = {6, 7, 8, 9}; int *ptr = y + 2; printf(“%dn”, ptr[ 1 ] ); What is printed when the sample code above is executed? a) 6 b) 7 c) 8 d) 9 Ans: d

27. 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 = %dn”, i); What will the output of the sample code above be? a) i = 5 b) i = 8 c) i = 9 d) i = 10 Ans: a

28. What will be output if you will compile and execute the following c code? void main() { if(printf(“cquestionbank”))

Page 22: Computer Programming “C language”

22

printf(“I know c”); else printf(“I know c++”); } (a) I know c (b) I know c++ (c) cquestionbankI know c (d) cquestionbankI know c++ (e) Compiler error Answer: (c)

29.What will be output if you will compile and execute the following c code? #define call(x) #x void main(){ printf(“%s”,call(c/c++)); } (a)c (b)c++ (c)#c/c++ (d)c/c++ (e)Compiler error Answer: (d)

30. What will be output if you will compile and execute the following c code? #define message “union is power of c” void main() { clrscr(); printf(“%s”,message); getch(); } (a) union is power of c (b) union is power of c (c) union is Power of c (d) Compiler error (e) None of these Answer: (b)

31. What will be output if you will compile and execute the following c code? void main(){ int a=25; clrscr(); printf(“%o %x”,a,a); getch(); } (a) 25 25 (b) 025 0x25 (c) 12 42 (d) 31 19

Page 23: Computer Programming “C language”

23

(e) None of these Answer: (d)

32. What will be output if you will compile and execute the following c code? void main() { int i=0; if(i==0){ i=((5,(i=3)),i=1); printf(“%d”,i); } else printf(“equal”); } (a) 5 (b) 3 (c) 1 (d) equal (e) None of above Answer: (c)

33.What will be output if you will compile and execute the following c code? int extern x; void main() printf(“%d”,x); x=2; getch(); } int x=23; (a) 0 (b) 2 (c) 23 (d) Compiler error (e) None of these Answer: (c)

34.What will be output if you will compile and execute the following c code? void main(){ int a,b; a=1,3,15; b=(2,4,6); clrscr(); printf(“%d “,a+b); getch(); } (a) 3 (b) 21 (c) 17 (d) 7

Page 24: Computer Programming “C language”

24

(e) Compiler error Answer: (d)

35.What will be output if you will compile and execute the following c code? void main(){ static main; int x; x=call(main); clrscr(); printf(“%d “,x); getch(); } int call(int address){ address++; return address; } (a) 0 (b) 1 (c) Garbage value (d) Compiler error (e) None of these Answer: (b)

36. What will be output if you will compile and execute the following c code? #include “string.h” void main(){ clrscr(); printf(“%d %d”,sizeof(“string”),strlen(“string”)); getch(); } (a) 6 6 (b) 7 7 (c) 6 7 (d) 7 6 (e) None of these Answer: (d) 37. Write c program which display mouse pointer and position of pointer.(In x coordinate, y coordinate)? Answer: #includeâ€?dos.hâ€? #includeâ€?stdio.hâ€? void main() { union REGS i,o; int x,y,k; //show mouse pointer i.x.ax=1; int86(0x33,&i,&o); while(!kbhit()) //its value will false when we hit key in the key board {

Page 25: Computer Programming “C language”

25

i.x.ax=3; //get mouse position x=o.x.cx; y=o.x.dx; clrscr(); printf(“(%d , %d)”,x,y); delay(250); int86(0x33,&i,&o); } getch(); }

38.What will be output if you will compile and execute the following c code? void main(){ int huge*p=(int huge*)0XC0563331; int huge*q=(int huge*)0xC2551341; *p=200; printf(“%d”,*q); } (a)0 (b)Garbage value (c)null (d) 200 (e)Compiler error Answer: (d) 39.What will be output if you will compile and execute the following c code? struct marks{ int p:3; int c:3; int m:2; }; void main(){ struct marks s={2,-6,5}; printf(“%d %d %d”,s.p,s.c,s.m); } (a) 2 -6 5 (b) 2 -6 1 (c) 2 2 1 (d) Compiler error (e) None of these Answer: (c) 40.What will be output if you will compile and execute the following c code? void main(){ if(printf(“cquestionbank”)) printf(“I know c”); else

Page 26: Computer Programming “C language”

26

printf(“I know c++”); } (a) I know c (b) I know c++ (c) cquestionbankI know c (d) cquestionbankI know c++ (e) Compiler error Answer: (c)

41.What will be output if you will compile and execute the following c code? #define call(x) #x void main(){ printf(“%s”,call(c/c++)); } (a)c (b)c++ (c)#c/c++ (d)c/c++ (e)Compiler error Answer: (d)

42. What will be output if you will compile and execute the following c code? #define message “union is power of c” void main(){ clrscr(); printf(“%s”,message); getch(); } (a) union is power of c (b) union ispower of c (c) union is Power of c (d) Compiler error (e) None of these Answer: (b)

43. What will be output if you will compile and execute the following c code? void main(){ int a=25; clrscr(); printf(“%o %x”,a,a); getch(); } (a) 25 25 (b) 025 0x25 (c) 12 42 (d) 31 19 (e) None of these Answer: (d)

Page 27: Computer Programming “C language”

27

44. What will be output if you will compile and execute the following c code? void main(){ int i=0; if(i==0){ i=((5,(i=3)),i=1); printf(“%d”,i); } else printf(“equal”); } (a) 5 (b) 3 (c) 1 (d) equal (e) None of above Answer: (c)

45.What will be output if you will compile and execute the following c code? int extern x; void main() printf(“%d”,x); x=2; getch(); } int x=23; (a) 0 (b) 2 (c) 23 (d) Compiler error (e) None of these Answer: (c)

46.What will be output if you will compile and execute the following c code? void main(){ int a,b; a=1,3,15; b=(2,4,6); clrscr(); printf(“%d “,a+b); getch(); } (a) 3 (b) 21 (c) 17 (d) 7 (e) Compiler error

Answer: (d)

Page 28: Computer Programming “C language”

28

47.What will be output if you will compile and execute the following c code? void main(){ static main; int x; x=call(main); clrscr(); printf(“%d “,x); getch(); } int call(int address){ address++; return address; } (a) 0 (b) 1 (c) Garbage value (d) Compiler error (e) None of these Answer: (b)

48.What will be output if you will compile and execute the following c code? #include “string.h” void main(){ clrscr(); printf(“%d %d”,sizeof(“string”),strlen(“string”)); getch(); } (a) 6 6 (b) 7 7 (c) 6 7 (d) 7 6 (e) None of these Answer: (d)

49.What will be output if you will compile and execute the following c code? void main(){ int huge*p=(int huge*)0XC0563331; int huge*q=(int huge*)0xC2551341; *p=200; printf(“%d”,*q); } (a)0 (b)Garbage value (c)null (d) 200 (e)Compiler error Answer: (d)

50.What will be output if you will compile and execute the following c code? struct marks{

Page 29: Computer Programming “C language”

29

int p:3; int c:3; int m:2; }; void main(){ struct marks s={2,-6,5}; printf(“%d %d %d”,s.p,s.c,s.m); } (a) 2 -6 5 (b) 2 -6 1 (c) 2 2 1 (d) Compiler error (e) None of these Answer: (c)

C Programming Objective Questions Pdf ::

51.What will be output if you will compile and execute the following c code? void main(){ if(printf(“cquestionbank”)) printf(“I know c”); else printf(“I know c++”); } (a) I know c (b) I know c++ (c) cquestionbankI know c (d) cquestionbankI know c++ (e) Compiler error Answer: (c)

52.What will be output if you will compile and execute the following c code? #define call(x) #x void main(){ printf(“%s”,call(c/c++)); } (a)c (b)c++ (c)#c/c++ (d)c/c++ (e)Compiler error Answer: (d)

53. What will be output if you will compile and execute the following c code? #define message “union is power of c” void main(){ clrscr(); printf(“%s”,message);

Page 30: Computer Programming “C language”

30

getch(); } (a) union is power of c (b) union ispower of c (c) union is Power of c (d) Compiler error (e) None of these Answer: (b)

54. What will be output if you will compile and execute the following c code? void main(){ int a=25; clrscr(); printf(“%o %x”,a,a); getch(); } (a) 25 25 (b) 025 0x25 (c) 12 42 (d) 31 19 (e) None of these Answer: (d)

55.What will be output if you will compile and execute the following c code? void main(){ int i=0; if(i==0){ i=((5,(i=3)),i=1); printf(“%d”,i); } else printf(“equal”); } (a) 5 (b) 3 (c) 1 (d) equal (e) None of above Answer: (c)

56.What will be output if you will compile and execute the following c code? int extern x; void main() printf(“%d”,x); x=2; getch(); } int x=23; (a) 0

Page 31: Computer Programming “C language”

31

(b) 2 (c) 23 (d) Compiler error (e) None of these Answer: (c)

57.What will be output if you will compile and execute the following c code? void main(){ int a,b; a=1,3,15; b=(2,4,6); clrscr(); printf(“%d “,a+b); getch(); } (a) 3 (b) 21 (c) 17 (d) 7 (e) Compiler error Answer: (d)

58.What will be output if you will compile and execute the following c code? void main(){ static main; int x; x=call(main); clrscr(); printf(“%d “,x); getch(); } int call(int address){ address++; return address; } (a) 0 (b) 1 (c) Garbage value (d) Compiler error (e) None of these Answer: (b)

59.What will be output if you will compile and execute the following c code? #include “string.h” void main(){ clrscr(); printf(“%d %d”,sizeof(“string”),strlen(“string”)); getch(); }

Page 32: Computer Programming “C language”

32

(a) 6 6 (b) 7 7 (c) 6 7 (d) 7 6 (e) None of these Answer: (d)

60.What will be output if you will compile and execute the following c code? void main(){ int huge*p=(int huge*)0XC0563331; int huge*q=(int huge*)0xC2551341; *p=200; printf(“%d”,*q); } (a)0 (b)Garbage value (c)null (d) 200 (e)Compiler error Answer: (d)

61. Who is father of C Language? A. Bjarne Stroustrup B. Dennis Ritchie C. James A. Gosling D. Dr. E.F. Codd Ans : B

62. C Language developed at _____? A. AT & T’s Bell Laboratories of USA in 1972 B. AT & T’s Bell Laboratories of USA in 1970 C. Sun Microsystems in 1973 D. Cambridge University in 1972 Ans : A

63. For 16-bit compiler allowable range for integer constants is ______ ? A. -3.4e38 to 3.4e38 B. -32767 to 32768 C. -32768 to 32767 D. -32668 to 32667 Ans : C

64. C programs are converted into machine language with the help of A. An Editor B. A compiler C. An operating system D. None of the above Ans : B

65. A C variable cannot start with A. An alphabet B. A number

Page 33: Computer Programming “C language”

33

C. A special symbol other than underscore D. both (b) and (c) Ans : D

66. Which of the following is allowed in a C Arithmetic instruction A. [] B. {} C. () D. None of the above Ans : C

67. Which of the following shows the correct hierarchy of arithmetic operations in C A. / + * – B. * – / + C. + – / * D. * / + – Ans : D

68. What is an array? A. An array is a collection of variables that are of the dissimilar data type. B. An array is a collection of variables that are of the same data type. C. An array is not a collection of variables that are of the same data type. D. None of the above. Ans : B

69. What is right way to Initialization array? A. int num[6] = { 2, 4, 12, 5, 45, 5 } ; B. int n{} = { 2, 4, 12, 5, 45, 5 } ; C. int n{6} = { 2, 4, 12 } ; D. int n(6) = { 2, 4, 12, 5, 45, 5 } ; Ans : A

70. An array elements are always stored in _________ memory locations. A. Sequential B. Random C. Sequential and Random D. None of the above Ans : A

71. What is the right way to access value of structure variable book{ price, page }? A. printf(“%d%d”, book.price, book.page); B. printf(“%d%d”, price.book, page.book); C. printf(“%d%d”, price::book, page::book); D. printf(“%d%d”, price->book, page->book); Ans : A

72. perror( ) function used to ? A. Work same as printf() B. prints the error message specified by the compiler C. prints the garbage value assigned by the compiler

Page 34: Computer Programming “C language”

34

D. None of the above Ans : B

73. Bitwise operators can operate upon? A. double and chars B. floats and doubles C. ints and floats D. ints and chars Ans : D

74. What is C Tokens? A. The smallest individual units of c program B. The basic element recognized by the compiler C. The largest individual units of program D. A & B Both Ans : D

75. What is Keywords? A. Keywords have some predefine meanings and these meanings can be changed. B. Keywords have some unknown meanings and these meanings cannot be changed. C. Keywords have some predefine meanings and these meanings cannot be changed. D. None of the above Ans : C

76. What is constant? A. Constants have fixed values that do not change during the execution of a program B. Constants have fixed values that change during the execution of a program C. Constants have unknown values that may be change during the execution of a program D. None of the above Ans : A

77. Which is the right way to declare constant in C? A. int constant var =10; B. int const var = 10; C. const int var = 10; D. B & C Both Ans : D

78. Which operators are known as Ternary Operator? A. ::, ? B. ?, : C. ?, ;; D. None of the avobe Ans : B

79. In switch statement, each case instance value must be _______? A. Constant B. Variable C. Special Symbol D. None of the avobe Ans : A

Page 35: Computer Programming “C language”

35

80. What is the work of break keyword? A. Halt execution of program B. Restart execution of program C. Exit from loop or switch statement D. None of the avobe Ans : C

81. What is function? A. Function is a block of statements that perform some specific task. B. Function is the fundamental modular unit. A function is usually designed to perform a specific task. C. Function is a block of code that performs a specific task. It has a name and it is reusable D. All the above Ans : D

82. Which one of the following sentences is true ? A. The body of a while loop is executed at least once. B. The body of a do … while loop is executed at least once. C. The body of a do … while loop is executed zero or more times. D. A for loop can never be used in place of a while loop. Ans : B

83. A binary tree with 27 nodes has _______ null branches. A. 54 B. 27 C. 26 D. None of the above Ans : D

84. Which one of the following is not a linear data structure? A. Array B. Binary Tree C. Queue D. Stack Ans : B

85. Recursive functions are executed in a? A. First In First Out Order B. Load Balancing C. Parallel Fashion D. Last In First Out Order Ans : D

86. Queue is a _____________ list. A. LIFO B. LILO C. FILO D. FIFO Ans : D

Page 36: Computer Programming “C language”

36

87. The statement print f (“%d”, 10 ? 0 ? 5 : 1 : 12); will print? A. 10 B. 0 C. 12 D. 1 Ans : D

88. To represent hierarchical relationship between elements, which data structure is suitable? A. Priority B. Tree C. Dqueue D. All of the above Ans : B

89. Which of the following data structure is linear type? A. Strings B. Queue C. Lists D. All of the above Ans : D

90. The statement printf(“%c”, 100); will print? A. prints 100 B. print garbage C. prints ASCII equivalent of 100 D. None of the above Ans : C

91. The _______ memory allocation function modifies the previous allocated space. A. calloc B. free C. malloc D. realloc Ans : D

92. Number of binary trees formed with 5 nodes are A. 30 B. 36 C. 108 D. 42 Ans : D

93. The “C” language is A. Context free language B. Context sensitive language C. Regular language D. None of the above Ans : A

94. The worst case time complexity of AVL tree is better in comparison to binary search tree for A. Search and Insert Operations B. Search and Delete Operations

Page 37: Computer Programming “C language”

37

C. Insert and Delete Operations D. Search, Insert and Delete Operations Ans : D

95. In which tree, for every node the height of its left subtree and right subtree differ almost by one? A. Binary search tree B. AVL tree C. Threaded Binary Tree D. Complete Binary Tree Ans : B

96. C is ______ Language? A. Low Level B. High Level C. Assembly Level D. Machine Level

97. The Default Parameter Passing Mechanism is called as A. Call by Value B. Call by Reference C. Call by Address D. Call by Name Ans : A

98. What is Dequeue? A. Elements can be added from front B. Elements can be added to or removed from either the front or rear C. Elements can be added from rear D. None of the above Ans : B

99. In which linked list last node address is null? A. Doubly linked list B. Circular list C. Singly linked list D. None of the above Ans : C

100. Which is the correct syntax to declare constant pointer? A. int *const constPtr; B. *int constant constPtr; C. const int *constPtr; D. A and C both Ans : D