Sei sulla pagina 1di 38

1.

C language has been developed by

A) Martin Richards

B) Bijarne Stroustrup

C) Dennis Ritche

D) Ken Thompson

2. int[ ] ={5,6,7,8,9} What is the value of a[3]?

A) 9

B) 8

C) 7

D) 6

3. C can be used on

A) Only MS-Dos operating System

B) Only Linux operating system

C) Only Windows operating system

D) All of the above

4. Float a[15], what is the size of array?

A) 17

B) 14

C) 15

D) 16

5. C programs are converted into machine language with the

help of

A) An Editor

B) A complier

C) An operating system

D) None of the above

6. Array is

A) Primary data type

B) Pointer data type


C) Heterogeneous data type

D) Homogenous data type

7. Which of the following is allowed in a C Arithmetic Instruction?

A) [ ]

B) { }

C) ( )

D) None of the above

8. To accept 100 different values into the array we require

A) Loop

B) If condition

C) Function

D) Structure

9. If a is an integer variable, a=7/3; will return a value

A) 2.5

B) 3

C) 0

D) 2

10. Pointer holds

A) Value of variable

B) Address of variable

C) Value and address of variable

D) Always null

11. Hierarchy decides which operator

A) is most important

B) is used first

C) is fastest

D) Operates on largest numbers

12. A pointer can hold


A) Single address at a time

B) Two addresses at a time

C) Number of addresses at a time

D) No address

13. An integer constant in C must have

A) At least one digit

B) At least one decimal point

C) A comma along with digits

D) Digits separated by commas

14. main() {

Int a=3, b=2, c*d*e;

d=&a; e=&b;

c=*d+*e;

Which one of the given answers is correct?

A) a=4, c-6

B) a=3, c=5

C) a=3, c=6

D) a=3, c=8

15. In C a variable cannot contain

A) Blank Spaces

B) Decimal Point

C) Hyphen

D) All of the above

16. Assume that variable x resides at memory location 1234, y at 1111 and p at 2222.

Int x=1, y=2, *p;

p=&x;

y=*p;

What will be the value of y after execution of above code?


A) 2

B) 1

C) 1234

D) 1111

17. Which of the following is FALSE in C?

A) Keywords can be used as variable names

B) Variable names can contain a digit

C) Variable names do not contain a blank space

D) Capital letters can be used in variables

18. If an integer occupies 4 bytes and a character occupies 1 byte of memory, each element of the
following structure would occupy how many bytes ?

struct name {

int age;

char name[30];

};

A) 30

B) 32

C) 34

D) 36

19. The expression x=4+2 % -8 evaluates to

A) -6

B) 6

C) 4

D) None of the above

20. A structure brings together a group of

A) items of the same data type

B) related data items and variables

C) integers with user defined names

D) floating points with user defined names


21. C language is available for which of the following operating systems?

A) DOS

B) Windows

C) Unix

D) All of the above

22. Which of the following are tokens in C?

A) Keywords

B) Variables

C) Constraints

D) All of the above

23. C was developed in the year …………………

A) Between 1969 to 1973

B) Between 1970 to 1974


C) Between 1965 to 1969

D) Between 1973 to 1979

24. Which escape character can be used to beep from speaker in C?

A) a

B) b

C) m

D) n

25. Which of the following is a keyword is used for storage class?

A) printf

B) external

C) auto

D) scanf

26. 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 iteration from beginning of loop

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

A) streams.h

B) stdio.h

C) stdlib.h

D) files.h

28. A compiler …………….

A) is a computer program

B) translates a high level language into machine language

C) is a part of software

D) editor

29. Explicit type conversion is known as ………………..


A) casting

B) conversion

C) disjunction

D) separation

30. A function popularly used C input function

A) scanf

B) printf

C) getch

D) Char

31. There is a unique function in C++ program by where all C++ programs start their execution with ……..

A) start()

B) begin()

C) main()

D) output()

32. Which of the following is not a jump statement in C++?

A) break
B) Goto

C) Exit

D) Switch

33. The memory address of the first element of an array is called ……………….

A) floor address

B) foundation address

C) first address

D) base address

34. C++ exception handling mechanism mainly uses how many keywords?

A) Four

B) Three

C) Two

D) None of the above


35. When an exception is thrown, it needs to be …………………

A) Executed

B) Handled appropriately

C) Resolved

D) None of the above

36. After defining the function template, the next step to call it in another function such as ………

A) int()

B) secondary()

C) template()

D) main()

37. A file stream refers to the flow of data between a ……………

A) Program and object

B) Program and stream

C) Program and file

D) None of the above


38. ……………… are one of the attributes of C++ that support run-time polymorphism.

A) Pointers

B) Derived classes

C) Virtual functions

D) Heap tree

39. which of the following header file does not exist?

A) iostream

B) string

C) sstring

D) sstream

40. To increase the value of c by one, which of the following is wrong?

A) c++;

B) c=c+1;

C) c+1=>c;
D) c+=1;

41. ‘C’ is often called a ….

A) Object oriented language

B) High level language

C) Assembly language

D) Machine level language

42. Each C preprocessor directive begins with ….

A) #

B) include

C) main()

D) {

43. C allows arrays of greater than two dimensions, who will determine this?

A) programmer

B) compiler

C) parameter
D) None of the above

44. The << operator is used for

A) Right shifting

B) Left shifting

C) Bitwise shifting

D) Bitwise complement

45. Set of values of the same type, which have a single name followed by an index is called

A) function

B) structure

C) array

D) union

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

A) String.h

B) Strings.h
C) file.h

D) strcpy()

47. scanf() can be used for reading …

A) double character

B) single character

C) multiple characters

D) no character

48. A variable which is visible only in the function in which it is defined is called

A) Static variable

B) auto variable

C) external variable

D) local variable

49. In the loop structure logical expression is checked at the ………………..of the loop.

A) first

B) end
C) middle

D) second

50. If an array is used as function argument, the array is passed

A) by value

B) by reference

C) by name

D) the array cannot be used as function argument

51. If is necessary to declare the type of function in the calling program if

A) Function returns an integer

B) Function returns a non-integer value

C) Function is not defined in the same file

D) Function is called number of times

52. Which escape character can be used to begin a new line in C ……..

A) a
B) m

C) b

D) n

53. Input/output function prototypes and macros are defined in which header file?

A) conio.h

B) stdlib.h

C) stdio.h

D) dos.h

54. What is the purpose of fflush() function?

A) flushes all streams and specified streams

B) flushes only specified stream

C) flushes input/output buffer

D) flushes file buffer

55. What does the following declaration mean?int(*ptr)[10].

A) ptr is array of pointers to 10 integers.


B) ptr is a pointer to an array of 10 integers

C) ptr is an array of 10 integers

D) ptr is an pointer to array

56. What will be output of the following C program? #include int main() {int goto=5; printf(“%d”,goto);
return 0;}

A) 5

B) 10

C) **

D) compilation error

57. Output of the following C program fragment is. x=5; y=x++; printf(“%d %d”, x,y);

A) 5, 6

B) 5, 5

C) 6, 5

D) 6, 6

58. What will be output of the following C program? #include int xyz=10; int main() { int xyz=20;
printf(“%d”, xyz); return 0;}

A) 10

B) 20
C) 30

D) compilation error

59. Following program fragment. main(){ printf(“%pn”, main( ) ); }

A) Prints the address of main function

B) Prints 0

C) Is an error

D) In an infinite loop

60. What will be output of the following program? #include int main() {int a=2, b=7, c=10; c=a==b;
printf(“%d”,c); return 0;}

A) 0

B) 7

C) 10

D) 2

61. What is the output of the following program segment? main( ) { long i=65536; printf(“%dn”, i); }

A) 0
B) 65536

C) -1

D) 65

62. What will be the output of the program? # include int main() {int a[5]={5,1,15,20,25}; int i, j, m;
i=++a[1]; j=a[1]++; m=a[i++]; printf(“%d, %d, %d”, i,j,m); return0;}

A) 2, 1, 15

B) 1, 2, 5

C) 3, 2, 15

D) 2, 3, 20

63. What is the output of the following program segment? main( ) { int=1; do { printf(“%d . . “, i); } while
(i–); }

A) 0 . . 1 . .

B) 1 . . 0 . .

C) 0

D) -1
64. Output of the program below is. int i; main( ) { printf(“%d”, i); }

A) 1

B) 0

C) -1

D) Null

65. What will be the output of the following program? main( ) { int i=5; printf(“%d”, i=++i==6); }

A) 0

B) 7

C) 6

D) 1

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

A) !

B) ~

C) #

D) ;

67. If the size of the array is less than the number of initializes 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

68. In C, if you pass an array as an argument to a function, what actually gets passed?

A) Value of elements in array

B) First element of the array

C) Base address of the array

D) Address of the last element of array

69. How many times the following loop be executed? { .. ch=’b’; while (ch>=’a’ && ch<==’z’) ch++; }

A) 0

B) 25

C) 26

D) 1
70. If a=8 and b=15 then the statement x=(a>b) ? a:b;

A) assigns a value 8 to x

B) gives an error message

C) assigns a value 15 to x

D) assigns a value 7 to x

71. What is the output of the following code. int n=0, m=1; do { printf(“%d”, m); m++; } while (m<=n);

A) 0

B) 2

C) 1

D) 4

72. A C program contains the following declaration int i=8, j=5 what would be the value of following
expression? abs(i-2*j)

A) 2

B) 4

C) 6

D) 8
73. The output of the following is . int a=75; printf(“%d%%”, a);

A) 75

B) 75%%

C) 75%

D) None of the above

74. How many times the following program would print (“abc”)? main( ) { printf(“nabc”); main( ); }

A) Infinite number of times

B) 32767 times

C) 65535 times

D) Till the stack does not overflow

75. Which of the following is the correct usage of conditional operators used in C?

A) a>b?c=30:c=40;

B) a>b?c=30;

C) max=a>b?a>c?a:c:b>c?b:c
D) return (a>b)?(a:b)

76) ‘C’ allows a three way transfer of control with the help of

A. Unary Operator

B. Relational Operator

C. Ternary Operator

D. Comparison Operator

77) Operators have hierarchy. It is used to know which operator ….

A. is most important

B. is used first

C. is faster

D. operators on large numbers

78) The statement that transfers control to the beginning of the loop is called ..

A. break statement

B. exit statement
C. continue statement

D. goto statement

79) C programming language was developed by ..

A. Dennis Ritche

B. Ken Thompson

C. Bill Gates

D. Peter Norton

80) The value that follows the keyword CASE may only be

A. constants

B. variable

C. number

D. semicolon

81) In a C language ‘a’ represents …

A. a digit

B. an integer
C. a character

D. a word

82) The statement which is used to terminate the control from the loop is

A. break

B. continue

C. goto

D. exit

83) The continue command cannot be used with ….

A. for

B. switch

C. do

D. while

84) A self contained block of statements that perform a coherent task of some kind is called a .

A. Monitor
B. Function

C. Program

D. Structure

85) Which among the following is a unconditional control structure?

A. do while

B. if else

C. goto

D. for

86) Recursion is sometimes called

A. Circular definition

B. Complex definition

C. Procedure

D. Union

87) Every program statement in a C program end with …

A. semicolon
B. comma

C. full stop

D. slash

88) The loop in which the statements within the loop are executed at least once is called

A. do-while

B. while

C. for

D. goto

89) The maximum length allowed in specifying the name of a C variable is ……..

A. 45

B. 31

C. 56

D. 78

90) The break statement causes an exit


A. Only from the innermost loop

B. Only from the innermost switch

C. From the innermost loop or switch

D. From the program

100) Which of the following is a unformatted console I/O function to get a string input?

A. puts

B. gets

C. clrscr

D. scanf

101) The operators << and >> are

A. assignment operator

B. relational operator

C. logical operator

D. bitwise shift operator

102) The operator & is used for ……..


A. Bitwise AND

B. Bitwise OR

C. Logical AND

D. Logical OR

103) Which of the following is FALSE in C

A. Keywords can be used as variable names

B. Variable names can contain a digit

C. Variable names do not contain a blank space

D. Capital letters can be used in variable names

104) The operator && is an example of ……….. operator.

A. assignment

B. increment

C. logical

D. relational
105) The control automatically passes the first statement after the loop in ..

A. Continue statement

B. Break statement

C. Switch statement

D. If statement

106) Which of the following is a scalar data type?

A. Float

B. Union

C. Array

D. Pointer

107) The given FOR loop is ..

for( ; ; ) { printf(” “); }

A. valid

B. invalid
C. indefinite

D. displays runtime error

108) In C, a union is ……

A. memory location

B. memory store

C. memory screen

D. memory space

109) The ……… statement causes immediate exit from the loop overriding the condition test ..

A. Exit

B. Break

C. Goto

D. None of the above

110) Pointers are of ……….

A. integer data type


B. character data type

C. unsigned integer data type

D. None of these

111) The keyword used to transfer control from a function back to the calling function is …

A. switch

B. goto

C. go back

D. return

112) Identify the invalid pointer arithmetic ……

A. addition of float value to a pointer

B. comparison of pointers that do not point to the element of the same array

C. subtracting an integer from a pointer

D. assigning the value 0 to a pointer variable

113) In C, if you pass an array as an argument to a function, what actually gets passed?

A. Value of elements in array


B. First element of the array

C. Base address of the array

D. Address of the last element of array

114) Header file in C contain ……

A. compiler commands

B. library functions

C. header information of C programs

D. operators for files

115) Which of the following cannot be checked in a switch-case statement?

A. Character

B. Integer

C. Float

D. Enum

116) The printf() function returns which value when an error occurs?
A. Positive value

B. zero

C. Negative value

D. None of these

117) When array elements are passed to a function with their values, it is called as …

A. end value

B. call by value

C. return value

D. first value

118) Which of the following is character oriented console I/O function?

A. getchar() and putchar()

B. gets() and puts()

C. scanf() and printf()

D. fgets() and fputs()

119) In the for loop structure there are ………. optional clauses.
A. one

B. two

C. three

D. four

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

A. string.h

B. strings.h

C. text.h

D. strcmp.h

121) 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. qualifies of data types


122) The real constant in C can be expressed in which of the following forms?

A. fractional form only

B. exponential form only

C. ASCI form only

D. Both fractional and exponential forms

123) 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

124) What will the function randomize() do?

A. returns a random number

B. returns a random number generator in the specified range

C. returns a random number generator with a random value based on time

D. return a random number with a given seed value


Shafqat Ullah
Shafqatullah345@gmail.com

Potrebbero piacerti anche