Sie sind auf Seite 1von 24

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

Answers:
1. C) Dennis Ritche
2. B) 8
3. D) All of the above
4. C) 15
5. B) A complier
6. D) Homogenous data type
7. C) ( )
8. A) Loop
9. D) 2
10. B) Address of variable

2. 1. Hierarchy decides which operator


3. A) is most important
4. B) is used first
5. C) is fastest
6. D) Operates on largest numbers
7.
8. 2. A pointer can hold
9. A) Single address at a time
10. B) Two addresses at a time
11. C) Number of addresses at a time
12. D) No address
13. 3. An integer constant in C must have
14. A) At least one digit
15. B) At least one decimal point
16. C) A comma along with digits
17. D) Digits separated by commas
18.
19. 4. main() {
20. Int a=3, b=2, c*d*e;
21. d=&a; e=&b;
22. c=*d+*e;
23. }
24. Which one of the given answers is correct?
25. A) a=4, c-6
26. B) a=3, c=5
27. C) a=3, c=6
28. D) a=3, c=8
29.
30. 5. In C a variable cannot contain
31. A) Blank Spaces
32. B) Decimal Point
33. C) Hyphen
34. D) All of the above
35.
36. 6. Assume that variable x resides at memory location 1234, y at 1111 and p at 2222.
37. Int x=1, y=2, *p;
38. p=&x;
39. y=*p;
40. What will be the value of y after execution of above code?
41. A) 2
42. B) 1
43. C) 1234
44. D) 1111
45.
46. 7. Which of the following is FALSE in C?
47. A) Keywords can be used as variable names
48. B) Variable names can contain a digit
49. C) Variable names do not contain a blank space
50. D) Capital letters can be used in variables
51.
52. 8. 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 ?
53. struct name {
54. int age;
55. char name[30];
56. };
57. A) 30
58. B) 32
59. C) 34
60. D) 36
61.
62. 9. The expression x=4+2 % -8 evaluates to
63. A) -6
64. B) 6
65. C) 4
66. D) None of the above
67.
68. 10. A structure brings together a group of
69. A) items of the same data type
70. B) related data items and variables
71. C) integers with user defined names
72. D) floating points with user defined names
73.
74. Answers:
1. B) is used first
2. A) Single address at a time
3. A) At least one digit
4. B) a=3, c=5
5. A) Blank Spaces
6. B) 1
7. A) Keywords …… variable names
8. C) 34
9. B) 6
10. B) related data items and variables

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

A) DOS

B) Windows

C) Unix

D) All of the above

2. Which of the following are tokens in C?

A) Keywords

B) Variables

C) Constraints

D) All of the above

3. C was developed in the year .....................

A) 1970

B) 1972

C) 1976

D) 1980

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

A) \a

B) \b

C) \m

D) \n

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


A) printf

B) external

C) auto

D) scanf

6. 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

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

A) streams.h

B) stdio.h

C) stdlib.h

D) files.h

8. A compiler ................

A) is a computer program

B) translates a high level language into machine language

C) is a part of software

D) editor

9. Explicit type conversion is known as ....................

A) casting

B) conversion

C) disjunction

D) separation
10. A function popularly used C input function

A) scanf

B) printf

C) getch

D) Char

76. Answers:

77.

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

D) All of the above

2. Which of the following are tokens in C?

D) All of the above

3. C was developed in the year .....................

A) 1970

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

B) \b

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

C) auto

6. Continue statement is used .............

A) to go to the next iteration in a loop

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

B) stdio.h
78.
8. A compiler ................

B) translates a high level language into machine language

9. Explicit type conversion is known as ....................


A) casting

10. A function popularly used C input function

A) scanf

1. 'C' is often called a ....

A) Object oriented language

B) High level language

C) Assembly language

D) Machine level language

2. Each C preprocessor directive begins with ....

A) #

B) include

C) main()

D) {

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

A) programmer

B) compiler

C) parameter

D) None of the above

4. The << operator is used for

A) Right shifting

B) Left shifting

C) Bitwise shifting

D) Bitwise complement

5. 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

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

A) String.h

B) Strings.h

C) file.h

D) strcpy()

7. scanf() can be used for reading ...

A) double character

B) single character

C) multiple characters

D) no character

8. 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

9. In the loop structure logical expression is checked at the ....................of the loop.

A) first

B) end

C) middle

D) second
10. 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

11. 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

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

A) \a

B) \m

C) \b

D) \n

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

A) conio.h

B) stdlib.h

C) stdio.h

D) dos.h

14. 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

15. 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

Answers:

1. 'C' is often called a ....

B) High level language

2. Each C preprocessor directive begins with ....

A) #

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

B) compiler

4. The << operator is used for

B) Left shifting

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

C) array

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

A) String.h

7. scanf() can be used for reading ...


C) multiple characters

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

D) local variable

9. In the loop structure logical expression is checked at the ....................of the loop.

A) first

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

B) by reference

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

B) Function returns a non-integer value

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

D) \n

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

C) stdio.h

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

A) flushes all streams and specified streams

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

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

1. 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
2. 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

3. 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

4. Following program fragment. main(){ printf("%p\n", main( ) ); }

A) Prints the address of main function

B) Prints 0

C) Is an error

D) In an infinite loop

5. 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

6. What is the output of the following program segment? main( ) { long i=65536; printf("%d\n", i); }

A) 0

B) 65536
C) -1

D) 65

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

8. 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

9. Output of the program below is. int i; main( ) { printf("%d", i); }

A) 1

B) 0

C) -1

D) Null

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

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

A) 5

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

C) 6, 5

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

B) 20

4. Following program fragment. main(){ printf("%p\n", main( ) ); }

A) Prints the address of main function

5. 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

6. What is the output of the following program segment? main( ) { long i=65536; printf("%d\n", i); }

A) 0

7. 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;}

C) 3, 2, 15

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

B) 1 . . 0 . .

9. Output of the program below is. int i; main( ) { printf("%d", i); }

B) 0

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

D) 1

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

A) !
B) ~

C) #

D) ;

2. 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

3. 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

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

A) 0

B) 25

C) 26

D) 1

5. 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
6. 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

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

8. The output of the following is . int a=75; printf("%d%%", a);

A) 75

B) 75%%

C) 75%

D) None of the above

9. 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

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

Answers:

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

D) ;

2. If the size of the array is less than the number of initializes then, ..........

B) generates an error message

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

C) Base address of the array

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

B) 25

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

C) assigns a value 15 to x

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

C) 1

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

8. The output of the following is . int a=75; printf("%d%%", a);

D) None of the above

9. How many times the following program would print ("abc")? main( ) { printf("\nabc"); main( ); }

A) Infinite number of times


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

C) max=a>b?a>c?a:c:b>c?b:c

1. 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()

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

A) break

B) Goto

C) Exit

D) Switch

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

A) floor address

B) foundation address

C) first address

D) base address

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

A) Four

B) Three

C) Two

D) None of the above


5. When an exception is thrown, it needs to be .....................

A) Executed

B) Handled appropriately

C) Resolved

D) None of the above

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

A) int()

B) secondary()

C) template()

D) main()

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

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

A) Pointers

B) Derived classes

C) Virtual functions

D) Heap tree

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


A) iostream

B) string

C) sstring

D) sstream

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

Answers:

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

C) main()

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

D) Switch

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

D) base address

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

B) Three

5. When an exception is thrown, it needs to be .....................

B) Handled appropriately

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

D) main()
7. A file stream refers to the flow of data between a ...............

C) Program and file

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

C) Virtual functions

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

C) sstring

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

C) c+1=>c;

1. In C++ ..................... operator is used for Dynamic memory allocation.


A) Scope resolution
B) Conditional
C) New
D) Membership access

2. Operators such as ...................... cannot be overloaded.


A) +
B) ++
C) : :
D) = =

3. The ...................... objects have values that can be tested for various error conditions.
A) osstream
B) ofstream
C) stream
D) ifstream

4. Which function return the current position of the get or put pointer in bytes.
A) tellg( )
B) tellp( )
C) tell( )
D) Both A and B

5. The first index number in an array starts with ............................ and the index number of an array of size n
will be ............
A) 0, n-1
B) 1, n-1
C) 0, n
D) 1, n

6. To overload an operator ..................... keyword must be used along with the operator to be overloaded.
A) Over
B) Overload
C) Void
D) Operator

7. What is the output of the program


#include<iostream.h>

void main()
{
int n=1;
cout<<endl<<"The numbers are;"<<endl;
do
{

cout <<n<<"\t";
n++;
} while (n<=100);
cout <<endl;
}

A) Print natural numbers 0 to 99


B) Print natural numbers 1 to 99
C) Print natural numbers 0 to 100
D) Print natural numbers 1 to 100

8. Everything defined at the program scope level (ie. outside functions and classes) is said to be ...............
A) local scope
B) regional scope
C) global scope
D) static scope

9. Because the lifetime of a local variable is limited and determined automatically, these variables are also
called ............................
A) automator
B) automatic
C) dynamic
D) static

10. ................ allows that a section of a program is compiled only if the defined constant that is specified as the
parameter has been defined, independently of its value.
A) #ifdef
B) #if
C) #define
D) #ifd

Answers
1. C) New
2. C) : :
3. D) ifstream
4. B) tellp( )
5. A) 0, n-1
6. D) Operator
7. D) Print natural numbers 1 to 100
8. C) global scope
9. B) automatic
10. A) #ifdef

1. When a function is defined inside a class, this function is called ………….


A) Inside function
B) Class function
C) Inline function
D) Interior function

2. Which of the following cannot be passed to a function?


A) Reference variable
B) Arrays
C) Class objects
D) Header files

3. State true of false.


i) We cannot make the function inline by defining a function outside the class.
ii) A member function can be called by using its name inside another member function of the same class, this is
known as nesting of member function.
A) True, True
B) True, False
C) False, True
D) False, False

4. Which of the following operators could be overloaded?


A) Size of
B) +
C) +=
D) ::

5. Which of the following is true about the static member variable in C++.
i) It is initialized to zero when the first object of its class is created. Other initialization is also permitted.
ii) It is visible only within the class, but its lifetime is the entire program.
A) i-True, ii-True
B) ii-False, ii-True
C) i-True, ii-False
D) i-False, iii-False

6. Which of the following keywords are used to control access to a class member?
A) default
B) break
C) protected
D) goto

7. What will be the values of x, m and n after execution of the following statements?
Int x, m, n;
m=10;
n=15;
x= ++m + n++;
A) x=25, m=10, n=15
B) x=27, m=10, n=15
C) x=26, m=11, n=16
D) x=27, m=11, n=16

8. The major goal of inheritance in C++ is


A) To facilitate the conversion of data types
B) To help modular programming
C) To facilitate the re usability of code
D) To extend the capabilities of a class

9. A variable is defined within a block in a body of a function. Which of the following are true?
A) It is visible throughout the function.
B) It is visible from the point of definition to the end of the program.
C) It is visible from the point of definition to the end of the block.
D) It is visible throughout the block.

10. The friend functions are used in situations where


A) We want to exchange data between classes
B) We want to have access to unrelated classes
C) Dynamic binding is required
D) We want to create versatile overloaded operators.

Answers
1. C) Inline function
2. D) Header files
3. C) False, True
4. B) +
5. B) ii-False, ii-True
6. C) protected
7. C) x=26, m=11, n=16
8. C) To facilitate the reusability of code
9. D) It is visible throughout the block.
10. A) We want to exchange … classes

Das könnte Ihnen auch gefallen