C and C++
C and C++
S.No. Question
1 The language of object oriented program is
[A] C
[B] FORTRAN
[C] PASCAL
[D] C++
Answer : D
2 The feature of object-oriented program is
(i). Emphasis on data
(ii). Program is divided in to objects
(iii). Only focus on data only
(iv). Data is hidden
[A] (i) only
[B] (i) & (ii) & (iv) only
[C] (iii) only
[D] (iv) and (i)
Answer : B
3 Object is of type
[A] Class type
[B] Predefined type
[C] Member function
[D] Data
Answer : A
4 A class is
[A] Collection of objects of similar type
[B] Collection of objects of dissimilar type
[C] Collection of member functions only
[D] Separated from the member function and object
Answer : A
5 The concept of object-oriented programming is
(i). Polymorphism
(ii). Encapsulation
(iii). Muti-threading
(iv) Inheritance
[A] (i) only
[B] (i), (ii), (iv) only
[C] (ii) and (iii) only
[D] (iv) only
Answer : B
6 Any C++ program execution starts from
[A] Main
[B] Above the main
[C] Without main
[D] Outside the main
Answer : A
7 The operator << is called as
[A] Bit-wise left shift
[B] Right shift
[C] Bit-wise right shift
[D] Left shift
Answer : A
8 The input/output statements contains in this header file
[A] Conio.h
[B] iostream.h
[C] stdio.h
[D] math.h
Answer : B
9 In C++ main() returns the value of type
[A] Integer
[B] String
[C] Byte
[D] Array
Answer : A
10 The reference data member of a class can be initialized
[A] In the constructor
[B] In the class declaration
[C] In the initialiser
[D] Cannot be initialized at all
Answer : A
11 A comment:
[A] Is a note that can be put in to the source code
[B] Is ignored by the compiler
[C] Starts with the /* character pair
[D] All of the above
Answer : D
12 Choose the correct answer
[A] C++ is more strongly typed than C
[B] C is more strongly typed than C++
[C] Size of literal character in C is that of a character
[D] Size of literal character in C++ is that of character
Answer : D
13 The cascading operators use
[A] Multiple use of << in one statement
[B] Single use of << in one statement
[C] Single use of >> in one statement
[D] Multiple of >> in one statement
Answer : A
14 C front
[A] Is front end of a C compiler
[B] Is the pre-processor of a C compiler
[C] Translates a C++ code to its equivalent C code
[D] None of the above
Answer : C
15 The C++ program implementations have extensions such as
[A] .c
[B] .C
[C] .pp
[D] All of the above
Answer : D
16 The C++ compiler would produce
[A] An object file
[B] An executable file
[C] Class file
[D] Text file
Answer : A
17 The output function in C++ used as
[A] Printf
[B] Scanf
[C] Cout
[D] Cin
Answer : C
18 The software development components
[A] Procedures
[B] Methods
[C] Tools
[D] All of the above
Answer : D
19 The classic software development life cycle contains
[A] 5 steps
[B] 6 steps
[C] 9 steps
[D] Only 2 steps
Answer : B
20 The life cycle method is called as
[A] Water fall model
[B] Win-win model
[C] Spiral model
[D] None
Answer : A
21 Problem space contains
[A] Objects defined in problem space during analysis
[B] Solution specifier objects defined during analysis
[C] Objects defined before the problem space
[D] Objects defined after the problem space
Answer : A
22 In a C++ program constant is defined
[A] Before main
[B] After main
[C] Any where but starting on new line
[D] Cannot be determined
Answer : C
23 In header files whether functions are
[A] Declared
[B] Defined
[C] Declared & determined
[D] Initialized
Answer : B
24 The polymorphism means in oops concept
[A] Single form only
[B] Single name to be used for more than one
[C] Different names to be used for more than one
[D] No name is used
Answer : B
25 Which of the following is procedural language
[A] Ada
[B] Small talk
[C] C++
[D] C
Answer : D
26 Which is/are the following object-oriented languages
[A] Smalltalk
[B] C++
[C] Eiffel
[D] All of the above
Answer : D
27 The C++ developed by
[A] Dennis Ritchie
[B] Bjarne Strostrup
[C] Clocksin & Mellish
[D] J Hame
Answer : B
28 Which header file contains the input stream
[A] ostream.h
[B] conio.h
[C] iostream.h
[D] stdio.h
Answer : B
29 The out put stream symbol in C++
[A] >>
[B] <>
[C] <<
[D] ::
Answer : C
30 In which of the following is literal
[A] String
[B] enum
[C] int
[D] float
Answer : B
31 What is the mechanism of scope resolution operator?
[A] To access the local variable in the function
To access the global variable from the function in
[B]
which local variable name same as global variable
[C] Don’t access the global variable from the function
[D] All of the above
Answer :
B
32 The variable name is
[A] Memory location of entity
[B] Constant
[C] Keyword
[D] Literal
Answer : A
33 The logical operator is
[A] &
[B] ^
[C] <<
[D] !
Answer : D
34 Which of the following is Bit-wise complement operator
[A] !
[B] &&
[C] >>
[D] ~
Answer : D
35 The unary operator is
[A] --
[B] ++
[C] –
[D] +-
Answer : C
36 The symbol defined using # define are called as
[A] Vector
[B] Macro
[C] Expression
[D] Integer
Answer : B
37 The statement terminator in C++ represented by
[A] :
[B] \n
[C] \t
[D] ;
Answer : D
38 String constants are represented within
[A] Single quotes
[B] Double quotes
[C] /* and */
[D] The braces
Answer : A
39 Which is not keyword of C++
[A] Const
[B] Main
[C] Sizeof
[D] Void
Answer : B
40 Tokens are separated by using
[A] :
[B] .
[C] ;
[D] Separator
Answer : D
41 (1)A definition allocates memory space for a variable
(2)A declaration allocates memory space for a variable
(3)A definition can occur multiple times
(4)A declaration can occur multiple times
Regarding the difference between a declaration & a definition of a
variable,
which of the above statements are true?
[A] (1)& (3) only
[B] (1)&(4) only
[C] (2)&(3) only
[D] (2)&(4) only
Answer : B
42 What is variable declaration?
[A] The assignment of properties to a variable
[B] The assignment of memory space to a variable
The assignment of properties & memory space to
[C]
variable
The assignment of properties and identification to a
[D]
variable
Answer :
D
43 The bit-wise AND is used for
[A] Masking
[B] Comparison
[C] Division
[D] Shifting bits
Answer : A
44 Explicit type conversion is known as
[A] Casting
[B] Coercion
[C] Options a& b
[D] Upward type conversion
Answer : C
45 The symbol # in the #define statements must commence from
[A] Any where in a line
[B] The first column of a line
[C] The first column of next line
[D] The first line
Answer : A
46 How the library functions are made available to a program?
[A] By using #define statements
[B] By linking loader to the program
[C] By using #include statements
[D] By using function declaration
Answer : C
47 main()
{
double x=1/2.0-1/2;
printf(“x=%.2f\n”,x);
}
What will be the output?
[A] X=0.00
[B] X=0.25
[C] X=0.50
[D] X=1.00
Answer : C
48 The associativity of assignment operator is
[A] Right to left
[B] Left to right
A for arithmetic expression and b for pointer
[C]
expression
A for pointer expression and b for arithmetic
[D]
expression
Answer : A
49 Dividing a program into functions
[A] Is the key to object –oriented programming
[B] Makes the program easier to conceptualize
[C] Makes the program run faster
[D] May increase the size of program
Answer : B
50 How many bytes occupies the char variable
[A] 4- bytes
[B] 2-bytes
[C] 1-byte
[D] 16-bits
Answer : C
51 Function prototyping is used to
[A] Describe the function
[B] Describe the number and type of arguments
[C] Describe the return value only
[D] Describe the parameters
Answer : B
52 When a argument is passed by reference
A variable is created in the function to hold the
[A]
arguments value
[B] The function can’t access the arguments value
A temporary variable is used in the calling program to
[C]
hold the argument value
The function access the argument original value in the
[D]
calling program
Answer :
A
53 Passing arguments to functions using reference is
[A] To affect only the actual arguments
[B] Same as the actual argument
[C] Interchanging their values
[D] No change in formal parameters
Answer : A
54 What is the output of the following program
Void swap (int &i, int &j)
{
int temp = i;
i = j;
j = temp;
}
main ()
{
int a = 10, b = 3;
swap (a, b);
Cout<<”” a = “” << a<<””<
Return 0;
}
[A] a=3&b=3
[B] a = 10 & b = 3
[C] a = 10 & b = 10
[D] a = 3 & b = 10
Answer : D
55 Which of the following parameter passing mechanism is/are
supported by C++ , but not by C?
(i). Pass by value
(ii). Pass by reference
(iii). Pass by constant reference
(iv). All the above
[A] (i) only
[B] (i) and (iii) only
[C] (ii) and (iv) only
[D] (iii) only
Answer : B
56 The parameter associated with the function during function call is
called
[A] Local parameter
[B] Global parameter
[C] Actual parameter
[D] Formal parameter
Answer : C
57 Inline function is a
[A] Function that is expanded in line when it involved
[B] Function that is expanded in block of statements
[C] Function that is inside the function
[D] Function cannot be expanded
Answer : A
58 Inline functions may not work in
(i). Switch
(ii). Static variable
(iii). For loop
(iv). Return statement exists
[A] (i) only
[B] (i) (ii) & (iv)
[C] (iii) & (iv)
[D] (iii) (i) only
Answer : B
59 The declaration void fun(int) indicates that fun is a function which
[A] Has no argument
[B] Returns nothing
[C] Both a and b
[D] Has argument
Answer : B
60 If many functions have the same name, which of the following, if
present,will be used by the compiler to invoke the correct function
to be used?
[A] The operator
[B] Object pointer
[C] Function signature
[D] All of the above
Answer : D
61 The virtual functions in C++ is analogous to _____ statements in
C
[A] Switch
[B] Go to
[C] For
[D] While
Answer : B
62 When the calling function calls called function, the function
should have a
[A] Prototype
[B] Data member
[C] Object
[D] Static member
Answer : A
63 Constructors are used in C++ to
[A] Declare an object
[B] Initialize an object
[C] Destroy the object
[D] Modify the object
Answer : B
64 The default constructor can be called with
[A] Parameters
[B] No parameters
[C] Arguments
[D] Integers
Answer : B
65 In the following program the function is defined as
Void g()
{
Car a;
Car b();
}
[A] Function
[B] Object
[C] Class
[D] Variable
Answer : A
66 A function abc is defined as (Assume h, g are declared as integers)
Void abc(int x = 0, int y = 0) { Printf (“%d, %d”, x, y); } Which of
the following function calls is/are legal?
[A] abc ();
[B] abc (h);
[C] abc (h, h);
[D] abc (h, g);
Answer : D
67 Function prototyping means
[A] Checking if the function is declared before its use
[B] Checking of the function has a forward reference
Checking of the function call confirms to the
[C]
declaration in type and number
[D] Checking if the function has no reference
Answer :
C
68 By passing values to the called functions by reference using swap
[A] Changes are made by the passed parameters
[B] No changes are made by the passed parameters
[C] Exchanged their values by the parameters
[D] Values are not exchanged by the parameters
Answer : C
69 Pass-by-value won’t work in C++, of the destination type is
[A] Abstract base class
[B] Derived class
[C] Static class
[D] Extended class
Answer : A
70 The standard output stream object in C++ is
[A] Printf
[B] Cout
[C] Cin
[D] Println
Answer : B
71 The standard input is in header file in C++
[A]
[B] <# iostream.h>
[C]
[D]
Answer : A
72 The global object is used by
[A] The entire program
[B] Only part of the program
[C] Not used by the program
[D] The functions
Answer : A
73 The use of the break statement in a switch statement is
[A] Optional
[B] Mandatory
[C] Not allowed
[D] To check an error
Answer : A
74 The statement to read a decimal value from the keyboard, into the
integer variable sum is
[A] cin >> sum;
[B] cin >> “sum”;
[C] cout << sum;
[D] cout << “sum”;
Answer : B
75 In C++, the goto statement causes control to
[A] Function
[B] A label
[C] A variable
[D] An operator
Answer : B
76 Overloaded functions in C++
[A] Are a group of functions with the same name
[B] All have the same number and type of arguments
[C] May fail unexpectedly due to stress
[D] Cause compilation problems
Answer : A
77 In C++ functions, a default argument has a value that
May be supplied by the calling program (or) the
[A]
function
[B] May have a constant value
[C] May have a variable value
[D] May not be supplied by the calling program
Answer : A
78 An enumerated data type brings together a group of
[A] Constant values integers with user-defined names
[B] Related data types
[C] Items of different data types
[D] Similar types of data
Answer : A
79 How many values can be returned from a function
[A] 2
[B] 1
[C] 4
[D] 5
Answer : B
80 Operator overloading is
[A] Making C++ operators work with objects
[B] Giving new meanings to existing C++ operators
[C] Making new C++ operators
[D] Both (a) and (b)
Answer : D
81 When you overload an arithmetic assignment operator, the result
[A] Must be returned
Goes in the subject of which the operator is a
[B]
member
[C] Goes in the object to the left of the operator
[D] Goes in the object to the right of the operator
Answer : C
82 In function, when an argument is passed by reference
[A] The function cannot access the argument’s value
A temporary variable is created in the calling program
[B]
to hold the arguments value
A variable is created in the function to hold the
[C]
argument’s value
The function access the argument’s original value in
[D]
the calling program
Answer :
C
83 Static automatic variable is used to
[A] Conserve memory when a function is not executing
[B] Make a variable visible to several functions
[C] Make a variable visible to only one function and retain
a value when a function is not executing
Make a variable visible to many functions when it is
[D] executing and retain a value when a function is not
executing
Answer :
D
84 Virtual functions in C++, allow you to
Use the same function call to execute member
[A]
function of objects from different class
[B] Create functions that have no body
Group of objects of different classes they can all be
[C]
accessed by the same code
Create an array of type pointer-to-base-class that can
[D]
hold pointers to derived class
Answer :
A
85 Pure virtual function is a virtual function that
[A] Has no body
[B] Is used in a base class
[C] Returns nothing
[D] Both a and b
Answer : D
86 Virtual base class is useful when
[A] It makes sense to use a base class with no body
There are multiple paths from one derived class to
[B]
another
Different functions in base and derived classes have
[C]
the same name
The identification of a function in a base class is
[D]
ambiguous
Answer :
D
87 In C++ container classes are used as
[A] Objects
[B] Templates
[C] Interfaces
[D] Default constructors
Answer : B
88 # include
main()
{
cout <<”Simple Enough”;
return(0);
}
[A] Simple enough
[B] 0
[C] Simple oops concept
[D] 1
Answer : B
89 Static data members are visible only
[A] Within the class
[B] Outside the class
[C] To number of classes
[D] To number of objects
Answer : A
90 A static member function is used to
Access only other static members declared in
[A]
different classes
Access only other static members declared in the
[B]
same class
Access all other data members declared within the
[C]
same class
Access all other data members declared out side the
[D]
class
Answer :
B
91 The keyword friend appears in
[A] The public section of a class
[B] The private section of a class
[C] The class allowing access to another class
[D] All of the above
Answer : D
92 A friend function is used in two classes as
[A] To access the private data of both classes
[B] To access the private data from one class only
[C] Not accessed by the classes
[D] To access the public and private data of both classes
Answer : A
93 Reusability is a desirable feature of a language as it
[A] Decreases the testing time
[B] Lowers the maintenance cost
[C] Both (a) & (b)
[D] Reduces the execution time
Answer : C
94 Choose the correct statement
[A] Recursive function cannot be declared as inline
[B] Recursive function can be declared as inline
Recursive function should not be declared outside the
[C]
main()
[D] Recursive function accepts integer arguments only
Answer :
A
95 cout stands for
[A] Class output
[B] Character output
[C] Common output
[D] Call output
Answer : C
96 The following program
Void abc (int &p)
{
Cout << p;
}
Void main (void)
{
float m = 11.23; abc (m);
Cout << m;
}
This code
[A] Results in compilation error
[B] Results in runtime error
[C] Prints 11.23
[D] Prints 11
Answer : A
97 The following program
Class abc;
Class def
{
int i1; //statement1
Protected: int i2,i3; //statement2
Friend abc;
};
Class abc
{
Public: void mn (def A)
}
Cout << (A.i1 = 3);
Cout << (A.i2 = 4);
Cout << (A.i3 = 5);
};
Void main ()
{def x1; abc x2; x2.mn(x1);}
[A] Will compile successfully if statement 1 is removed
[B] Will compile successfully of statement 2 is removed
[C] Will run successfully and print 345
Will compile successfully of statements 3 is
[D]
removed
Answer : C
98 If the function chg is coded as
int chg (const int & x)
{x = 10;
return (11);
}then
[A] It results in compile time error
[B] It results in run time error
[C] It prints 112
[D] It prints 1110
Answer : A
99 The storage class static can be used to
[A] Restrict the scope of an external identifier
[B] Preserve the exit value of variable
[C] Provide privacy to set of functions
[D] All of the above
Answer : D
100 C preprocessor
[A] Takes care of conditional compilation
[B] Don’t care of macros
[C] Takes care of static files
[D] Acts after compilation
Answer : A
101 Choose the correct answer
The scope of a macro definition extends the entire
[A]
program
The scope of macro definitions extends from the point
[B]
of definition to the end of the file
[C] New line is not a macro definition delimiter
The scope of a macro does not extends the entire
[D]
program
Answer :
A
102 Preprocessing is typically done
Either before or at the beginning of the compilation
[A]
process
[B] After compilation but before execution
[C] After loading
[D] Before loading
Answer :
A
103 Choose the correct answers
[A] ‘x’ is same as “x”
[B] Length of the string “x” is two
Unless otherwise specified, the first name in an enum
[C]
has the value1
[D] None of the above
Answer :
D
104 In C++ the limit on the length of a name
[A] 32 Characters
[B] 64 Characters
[C] No limit
[D] 128 Characters
Answer : C
105 The use of void are
(i). To specify the return type of a function, when it is not running
any value
(ii). Contains empty argument to a function
(iii). Contains arguments to a function
(iv). Doesn’t specify return value
[A] (i) only
[B] (ii) and (iv)
[C] (iv) only
[D] (iii) and (iv)
Answer : A
106 C++ character set includes
[A] Letters
[B] Digits
[C] Special characters
[D] All the above
Answer : D
107 The user defined data types
[A] Structure
[B] Function
[C] Array
[D] Pointer
Answer : A
108 The syntax of enum is
[A] Enum shape {circle, square, triangle};
[B] Enum shape = circle, square;
[C] Enum shape [];
[D] Enum {shape = circle, square};
Answer : A
109 The enum in C++
[A] Doesn’t permit an int value to convert it to an enum
[B] Permits int to Enum value
[C] Permits int to int value only
[D] Permits float value
Answer : A
110 The valid statement in enum
[A] Color background = blue;
[B] Color background = 7;
[C] Color background [] = blue;
[D] Color background = red, blue;
Answer : A
111 The enum in C++ is defined as
[A] Defined within a class and local to class
[B] Defined outside the class and global to class
[C] Defined in class and global to all class variable
[D] Not in class
Answer : A
112 The value of const declared in C++
[A] Cannot be modified by the program
[B] Modified by the program
[C] Modified only with length
[D] Modifies limited part of the program
Answer : A
113 This would be illegal in C
[A] Const int size = 10;
[B] int a = 10;
[C] int a[0] = 10;
[D] String name = ‘b’;
Answer : A
114 In C++ const variables are
[A] Global to file
[B] Local to file
[C] Not to be accessed
[D] Changed
Answer : B
115 C++ variable are case sensitive
[A] False
[B] Can’t say
[C] True
[D] Sometimes
Answer : C
116 In C++ static variable are
[A] Not to be accessed
[B] Global to class
[C] Can’t say
[D] Local only
Answer : D
117 Which of the following is allowed in C++
[A] Strict type compatibility than C
[B] Type compatibility not maintained
[C] Loosely held compatibility
[D] Tight compatibility
Answer : A
118 In a C++ program constant is defined
[A] Before main
[B] After main
[C] Anywhere but starting on new line
[D] In class only
Answer : C
119 The size of (int) is equivalent to
[A] Size of (‘x’)
[B] Size of (x)
[C] Size of (int x)
[D] Size of (char)
Answer : C
120 In C++ the size of (‘x’) equals to
[A] Size of (char)
[B] Size of (int)
[C] Size of (x)
[D] Size of (float)
Answer : A
121 In C++ all variables must be
[A] Declared before they are used
[B] Declared after they are used
[C] Not defined when they are involved
[D] Declared at run time
Answer : A
122 The dynamic initialization in C++
[A] Initialization of the variables at compile time
[B] Initialization takes place automatically
[C] Initialization of the variable at run time
[D] Initialization doesn’t takes place
Answer : C
123 A reference variable provides------- for previous defined variable
[A] Same name
[B] Alias name
[C] No name
[D] Can’t say
Answer : B
124 The size of integer
[A] 4 bytes
[B] 2 bytes
[C] 1 byte
[D] 32 bits
Answer : B
125 The output of the following is
Void f (int &n)
{x = x + 10}
main()
{
int m = 10
f(m);
Cout<
}
[A] 40
[B] 20
[C] Error
[D] 10
Answer : C
126 The new operator used for
[A] Memory allocation
[B] Creating Memory allocation
[C] Neither allocates nor deallocates
[D] Deallocate the variable
Answer : B
127 The scope of variable
[A] Extends from the point of its declaration itself only
Extends from the point of its declaration till the end
[B]
of the block
Extends from the point of its declaration outside of
[C]
the block
[D] Extends within the block
Answer :
B
128 The scope resolution operator is
[A] >
[B] :
[C] ::
[D] ;
Answer : C
129 The symbol :: used to
[A] Access the global variable
[B] Access the local variable
[C] Not access any variable
[D] Provide inheritance
Answer : A
130 The following output is
# include
int m = 10;
main( )
{int m = 20;
{int k = m;
Cout<<”k = ”<<K
Cout<<”m = ”<<M
}
Cout<< ::m
}
[A] 20, 20, 10
[B] 10, 20, 40
[C] 10, 40, 20
[D] 10, 10, 40
Answer : A
131 Malloc and calloc ( ) functions used to
[A] Allocate memory at compile time
[B] Allocate memory dynamically at run time
[C] Allocates static memory
[D] Deallocate memory
Answer : B
132 Pointer variable holds
[A] Address of the memory space allocated
[B] Value of the variable only
[C] Doesn’t contain value of the address
[D] Address of different variable
Answer : A
133 The new operator used in malloc( ) function is
[A] Automatically computes the size of object
[B] Returns the different pointer
Not to initialize the object while creating the memory
[C]
space
[D] used to allocate memory
Answer :
A
134 C++ permits which of the following type casting
[A] (type-name) (expression)
[B] (type-name) expression
[C] [type-name] expression
[D] type-name (expression)
Answer : D
135 Type casting is allowed in C++
[A] Implicitly
[B] Explicitly
[C] Both (a) & (b)
[D] some times only
Answer : B
136 Expressions is a combination of
[A] Pointers
[B] Strings
[C] Operators
[D] Constants
Answer : C
137 Reference is not same as pointer because
[A] A reference can never be null
[B] A reference once established can’t be changed
Reference doesn’t need an explicit differencing
[C]
mechanism
[D] All the above
Answer :
D
138 Const int v [] = {1, 2, 4}
Void f ( )
{Cout<
}
What is the output?
[A] 3
[B] 5
[C] Error
[D] 4
Answer : B
139 In C++ the object is defined as
[A] Instance of the class
[B] Not a member of the class
[C] Template
[D] Vector
Answer : A
140 The reference data member of a class can be initialized
[A] In the constructor
[B] In the class declaration
[C] In the initialiser list
[D] Cannot be initialized at all
Answer : B
141 A class having no name
[A] Is not allowed
[B] Cannot have a constructor
[C] Can have a destructor
[D] Can be passed as an argument
Answer : B
142 A constructor is called whenever
[A] An object is declared
[B] Object is used
[C] A class is declared
[D] A class is used
Answer : A
143 The difference between structure and class is by default
The members of a class are private and structures are
[A]
public
The members of a class are public and structures are
[B]
private
[C] There is no difference
[D] None
Answer :
A
144 The private access specifier is defined as follows
[A] Members can be accessed only outside the class
[B] Members can be accessed only within the class
[C] Members not accessed by within the class
[D] Members treated as functions
Answer : B
145 By default the members of a class are
[A] Protected
[B] Public
[C] Private
[D] Object
Answer : C
146 Binding of data and functions in to single unit is referred to as
[A] Data hiding
[B] Polymorphism
[C] Message passing
[D] Encapsulation
Answer : D
147 Constructors must have the
[A] Same name as class
[B] Different name as class
[C] Default name
[D] Same as main() function
Answer : A
148 Classes are useful because they
[A] Are removed from memory when not in use
[B] Permit data to be hidden from other class
[C] Bring together all aspects of an entity in one place
[D] Can closely model objects in the real world
Answer : B
149 Copy constructor is invoked when
[A] A function returns by value
[B] An argument is passed by value
[C] A function returns for reference
[D] An argument is passed by reference
Answer : A
150 A C++ stream is
[A] The flow of control through a function
[B] Flow of data from one place to another
[C] Associated with a particular class
[D] A file
Answer : B
151 The public files in a class library usually contain
[A] Constant definitions
[B] Member function definitions
[C] Class declarations
[D] Variable definitions
Answer : C
152 When a language has the capability to produce new data types, it
is called
[A] Extensible
[B] Overloaded
[C] Encapsulated
[D] Reprehensible
Answer : A
153 What is a structure?
[A] Collection of same data types
[B] Collection of variables
[C] Collection of heterogeneous data
[D] Collection of objects
Answer : C
154 Overloading is otherwise known as
[A] Virtual polymorphism
[B] Transient polymorphism
[C] Pseudo polymorphism
[D] Polymorphism
Answer : D
155 Assume that a program contains the following three statements?
Char itemname [10] = “ “;
Cout <<”Enter name::”;
Cin >> itemname;
If, after executing this program, enter two words Redcoat, C++
will store _____in the itemname
[A] Coat
[B] Red
[C] Red coat
[D] Cold
Answer : C
156 In the statement
return-type class-name :: function name ()
{
Function body
}
Scope of the function restricted to specified class
[A]
name only
[B] Scope of the function to different classes
[C] Restriction of total class
[D] Function not executed
Answer :
A
157 The function putdata() has been defined inside the class and
therefore behaves like
[A] A string
[B] Inline function
[C] A string
[D] Constructor
Answer : B
158 Constructors cannot be
[A] Abstract class
[B] Declared
[C] Virtual
[D] None
Answer : C
159 Constructors can return type?
[A] Integer
[B] String
[C] 0
[D] Don’t return
Answer : C
160 Let class APE be a friend of class SAPIEN. Let class HUMAN is
a child class of SAPIEN and let MONKEY be a child class of
APE. Then
[A] SAPIEN is not a friend of APE
[B] APE is not a friend of HUMAN
[C] MONKEY is not a friend of SAPIEN
[D] All the above
Answer : D
161 If a file is opened in r+ mode then
[A] Reading is not possible
[B] Writing is possible
[C] It will be created if it does not exist
[D] All the above comments are true
Answer : B
162 The fseek feature
[A] Needs two arguments
[B] Makes the rewind feature unnecessary
Is meant for checking whether a given file exists or
[C]
not
[D] Need no arguments
Answer : B
163 Object oriented program is based on
[A] Function abstraction
[B] Data abstraction
[C] System abstraction
[D] None
Answer : B
164 Establishment of communication among objects in C++ is through
[A] Data hiding
[B] Binding
[C] Message passing
[D] Polymorphism
Answer : C
165 In a class member functions are defined
[A] Only inside the class
[B] Only outside the class
[C] Neither inside nor outside the class
[D] Both inside and outside the class
Answer : D
166 The mechanism of binding the function to class using the operator
is
[A] Scope resolution operator (: :)
[B] Arithmetic operator (+)
[C] Assignment operator (=)
[D] Operand operator (&)
Answer : A
167 A inline member function is treated like
[A] Preprocessor
[B] Macro
[C] Method
[D] Object
Answer : B
168 In C++ program any call to input line member function in a
program replaced by itself is called__________
[A] Inline function
[B] Macro expansion
[C] Inline expansion
[D] Macro function
Answer : C
169 A member function prototype defined within a class is defined by
using which keyword
[A] Public
[B] No keyword
[C] Private
[D] Void
Answer : B
170 In a class the access specifier protected members are significantly
used in
[A] Polymorphism
[B] Overloading
[C] Inheritance
[D] Message passing
Answer : C
171 The size of vector object by creating an object is known only
[A] At runtime
[B] At compile time
[C] At creation
[D] All the above
Answer : A
172 A copy of the object is passed to function and any modifications
made to the object is not reflected in the object used to call the
function is_______
[A] Pass-by-reference
[B] Pass-by-value
[C] Pass-by-pointer
[D] Pass-by-address
Answer : B
173 The parameter passing pointer is
Only the address of the object is passed and not a
[A]
copy of the entire object
The address of the object and copy of the entire object
[B]
is passed
[C] Only the entire object is passed
[D] All of the above
Answer :
A
174 In C++ class the friend class
Allow the functions to declare public member of the
[A]
class
Allow the functions to access even the private
[B]
members of class
Disallows the functions to access even the private
[C]
members of the class
[D] None
Answer :
B
175 A friend function posses __________________
The scope of the friend function is not limited to the
[A]
class
The friend function cannot be called using the object
[B]
of the class
The friend function can be either declared in the
[C] private (or) public part of a class without affecting its
meaning
[D] All of the above
Answer :
D
176 The following program
Class A
{Private:
int value;
Public:
Void setVal(int v)
{Value = v;}
int getVal()
{return (Value);}
};
Void decrement (A & a)
a. Value
;
Class B
{Public:
Void touch (A & a)
{a. Value ++;}
};
[A] Run successfully
[B] Will not compile
[C] Run time error
[D] Return value
Answer : B
177 The order of execution of constructor of following declaration will
be Class derived: public base, virtual B
[A] Derived, Base, B
[B] B, Base, Derived
[C] Derived, B, Base
[D] Base, B, Derived
Answer : B
178 Structure member have _____________ accessibility by default
[A] Private
[B] Abstract
[C] Void
[D] Public
Answer : D
179 Static data members are accessed like variables
[A] Global
[B] Local
[C] Neither global nor local
[D] Can’t be determined
Answer : A
180 Choose the correct statement?
Static functions can’t access only the static members
[A]
of declared in the same class
Static functions can access all the static members of
[B]
declared different classes
Static functions can access only the static members
[C]
declared in the same class
[D] All of the above
Answer :
C
181 The ability to create user defined data types for modeling real
world object is
[A] Data encapsulation
[B] Data abstraction
[C] Data hiding
[D] Message passing
Answer : B
182 An object is destroyed which is invoked
[A] Constructor
[B] Default Constructor
[C] Destructor
[D] All of the above
Answer : C
183 Constructor overloading mechanism is
Have the same name as the class and differ in their
[A]
signatures
Have the different name as the class and same as
[B]
signature
[C] Have the same name as the class and as signature
[D] Cannot be determined
Answer :
A
184 The class is having ______________ destructor
[A] More than 1
[B] Only 2
[C] Only 1
[D] 4
Answer : C
185 Allocation of memory to objects at the time of their construction is
[A] Runtime construction
[B] Dynamic construction
[C] Dynamic destruction
[D] Compile time construction
Answer : B
186 Class A
{
int i1;
protected:
int i2;
public:
int i3;
};
Class B: public A
{
Public:
int I4;
};
Class C: B
{};
In the above program the variable i2 is accessible
[A] To a public function in Class A
[B] To a public function in Class B
[C] To a public function in Class C
[D] All the above
Answer : D
187 The following program shows
Class x
Private:
-----
Public:
x (x obj);
[A] Runs
[B] Error
[C] Correct
[D] Run time error
Answer : B
188 A constructor having a reference to an instance of its own class as
an argument is
[A] Dummy constructor
[B] Parameterized constructor
[C] Copy constructor
[D] Default constructor
Answer : C
189 Constant data members are
[A] Read only data members
[B] Write only data members
[C] Both read and write data members
[D] Neither read nor write data members
Answer : A
190 A dynamic object is instantiated
[A] At compile time
[B] At run time
[C] Declaration time
[D] All the above
Answer : B
191 The dynamic memory allocation is created by using the operator
[A] Delete
[B] ENUM
[C] New
[D] Create
Answer : C
192 Pointer variables accessing the data (or) function member by using
the symbol
[A] &
[B] ->
[C] =
[D] =>
Answer : B
193 The syntax of reference to dynamic objects
[A] Class Name *Ref obj = & (new Class Name);
[B] Class Name (new Class Name) = & Ref Obj;
[C] Class Name & Ref Obj = * (new Class Name);
[D] None
Answer : C
194 The operator overloading feature of C++ is one of the following
[A] Polymorphism
[B] Function overloading
[C] Data abstraction
[D] Inheritance
Answer : A
195 The field operator in C++
[A] #
[B] “/t”
[C] ~
[D] &
Answer : C
196 Unary operator overloading is the mechanism of ____________
Overloading without explicit arguments to an
[A]
operator function
Overloading with a single explicit argument to an
[B]
operator function
[C] Overloading with more explicit arguments to function
[D] All of the above
Answer :
A
197 The binary operator is
[A] One explicit argument
[B] More than two explicit arguments
[C] Two explicit arguments
[D] No explicit argument
Answer : C
198 In the following relation the imaginary part is
C = x 1 + i y 1;
[A] xi
[B] y1
[C] x 1 + iy 1
[D] Can’t be determined
Answer : B
199 Which of the following correct prototype for insertion operator
overloading
[A] Ostream * operator, << (ostream s, int);
[B] Ostream operator, << (ostream s, int);
[C] Ostream s operator, << (ostream s);
[D] Ostream s operator, << (ostream s, int);
Answer : C
200 The concatenation of strings is performed by using which the
perpendicular library function _____________
[A] Str append ()
[B] Str Cat ()
[C] Str Name ()
[D] String ()
Answer : B
201 Which is the correct syntax in C++
[A] Weight = (float) age;
[B] Weight = float (age);
[C] Weight = (float) (age);
[D] Weight = float age;
Answer : B
202 In which of the following function the arguments required to be
explicitly passed to the function and process them explicitly
[A] Member function
[B] Constant function
[C] User defined function
[D] Friend function
Answer : D
203 The following program output is
Class fig2d
{int dim1, dim 2;
Public:
fig2d()
{dim1 = 5; dim2 = 6;}
Virtual void operator << (ostream & rhs);
};
Void fig2d :: operator << (ostream & rhs)
{rhs < dim1 <<””<< this-> dim2 <<””}
}
Void main()
{
fig2d obj1;
fig2d obj2;
obj1 << Cout;
obj2 << Cout;
}
[A] 5
[B] 5, 6
[C] 6
[D] 6, 5
Answer : D
204 Struct emp
{
int sal = 10000;
int id = 20;
}s1;
Void main ()
{Cout << s1.sal <<””<< s1.id;
}
What is the output?
[A] 0, 0
[B] 1000, 20
[C] Error
[D] 20, 1000
Answer : C
205 What is structure
[A] Collection of same data types
[B] Collection of variables
[C] Collection of heterogeneous data
[D] Collection of dissimilar data types
Answer : C
206 Structure declaration starts with the keyword
[A] Enum
[B] Struct
[C] Class
[D] Extern
Answer : B
207 The syntax of array of structures is
[A] Array Name [index];
[B] Structure Name = Array Name [index];
[C] Structure Name Array Name [index];
[D] Struct Array [0];
Answer : C
208 The union stated as
[A] More than one variable in the same memory area
[B] Only limited variables in the different memory
[C] Only collection of constant variables
[D] both a& c
Answer : A
209 The technique of building new classes from existing classes is
called as
[A] Polymorphism
[B] Inheritance
[C] Encapsulation
[D] Data binding
Answer : B
210 class dog : public x, public y is an instance of
[A] Multiple inheritance
[B] Repeated inheritance
[C] Linear inheritance
[D] Homogeneous inheritance
Answer : A
211 Choose the incorrect statement
[A] A destructor is not inherited
[B] A constructor cannot be virtual
[C] A destructor cannot be virtual
[D] A constructor is not inherited
Answer : C
212 A class contains so many number of objects is called as-----class
[A] Abstract
[B] Container
[C] Vector
[D] Interface
Answer : B
213 In inheritance mechanism the protected member can be accessed
by--
[A] Only out side of the class
[B] Both within the class & outside of the class
[C] Only within the class
[D] Cannot play role in inheritance
Answer : C
214 The members& member functions declared as protected in base
class can be accessed by
[A] Only member functions of the base class
[B] Only member functions of the derived class
[C] Both member functions of the base & derived class
[D] Cannot directly accessed within the class
Answer : C
215 If a method is to be an interface between the outside world and a
class, it has to be declared as--------
[A] Private
[B] Protected
[C] Public
[D] External
Answer : C
216 Derived class can be----------
[A] Does not inheriting the properties of base class
[B] Inheriting the properties of base class
[C] Neither inheriting nor creating new functions
[D] All of the above
Answer : B
217 The derivation of derived class from the base class can be
represented by using -------- symbol
[A] ::
[B] &&
[C] :
[D] *&
Answer : C
218 Protected members of the base class become
[A] Public members of the derived class
[B] Private members of the base class
[C] Private members of the derived class
[D] Public members of the outside of the class
Answer : C
219 A derived class cannot be inherits --------from base class
[A] Data members & member functions
[B] Constructor
[C] Destructor
[D] Both b & c
Answer : D
220 A single inheritance mechanism syntax is---------
[A] Class Dog : public Mow ,public Animal
[B] Class Dog : public Animal
[C] Class Animal : public Dog : public Mow
[D] Class Dog : public x, public y
Answer : B
221 class Base
{
public:
void display(){cout<<”\n Display Base”;}
virtual void show(){cout<<”\n show base”;}
};
class Derived : public Base{
public:
void display(){coutt<<”\n display derived”;}
void show(){cout<<”\n show derived”;}
};
int main(){
Base B;
Derived D;
Base *bptr;
bptr=&B;
bptr->display();
bptr->show();
bptr=&D;
bptr->display();
bptr->show();
return 0;}
what will be the out put of this program?
display base
show base
[A]
display derived
show derived
Display Base
show base
[B]
display base
show derived
[C] display base
show base
display base
show base
display base
show derived
[D]
display derived
show base
Answer : B
222 The mechanism of inheriting properties of existing class and it
contains own features is& functions is called as-------
[A] abstract class
[B] external class
[C] base class
[D] derived class
Answer : D
223 Choose the correct statement
[A] Base class unchanged, using derived class
[B] Base class changed , using derived class
Base class can be accessed properties defined in the
[C]
derived class of its own
Constructor of base class can be accessed by derived
[D]
class
Answer :
A
224 The derivation of a class from another class is called---
[A] Multiple inheritance
[B] Multilevel inheritance
[C] Multi path inheritance
[D] Hybrid inheritance
Answer : B
225 The base class members might be needed in the derived class can
be declared as-------
[A] Protected
[B] Private
[C] public
[D] external
Answer : A
226 In inheritance mechanism the constructor must be defined as-----in
base & derived class
[A] private
[B] protected
[C] public
[D] const
Answer : C
227
class B class D: private B
private:
{ int privateD;
private: protected:
protected: public:
}}; a=publicB;//statement3
}};
}
while(0)
{
[B] body of the loop
}
while(1)
{
[C] body of the loop
while( )
[D] {
body of the loop
}
Answer : A
1053 The while is
[A] test condition controlled statement
[B] entry controlled loop statement
[C] entry controlled condition statement
[D] test controlled statement
Answer : B
1054 The while is executed
[A] even if the test condition is false
[B] at least once even if the test condition is false
[C] only if the test condition is true
[D] only once if the test condition is true
Answer : C
1055 Identify the loop constructs?
[A] goto
[B] break
[C] if else
[D] while
Answer : D
1056 Which of the following is not a unconditional construct?
[A] goto
[B] break
[C] continue
[D] while
Answer : D
1057 Which of the following is not a selective control structure?
[A] if-else
[B] if-else-if
[C] switch-case
[D] while
Answer : D
1058 Which of the following is an infinite loop?
[A] while (1){…}
[B] while (0) {…}
[C] while( ) {…}
[D] while (µ){…}
Answer : A
1059 Which of the following is an infinite loop?
[A] while (!0){…}
[B] while (0) {…}
[C] while( ) {…}
[D] while (µ){…}
Answer : A
1060 while (a < 10)
{ printf(“%d\n”, a);
a ++;
}
What is the output of the above statement?
[A] numbers from 1 to 10
[B] numbers from 10 to 1
[C] even numbers from 1 to 10
[D] odd numbers from 10 to1
Answer : A
1061 What is the output of the following program?
int count = 11;
while (--count +1);
printf (“count down is %d\n”, count);
[A] -1
[B] count down is -1
[C] does not execute
[D] gives an error
Answer : B
1062 What is the output of the following program?
# define TRUE 0
main ()
{
while (TRUE)
{ ---
}
}
[A] The statements in the loop will be executed
[B] gives an error while executing
[C] This wont go into the loop as TRUE is defined as 0
[D] the statements in the loop will not be executed
Answer : C
1063 The minimum number of times a while loop is executed is
_________
[A] 0
[B] 1
[C] continues till the end of the loop
[D] does not execute even if the loop is correct
Answer : A
1064 while( x = 10)
{
……
}
results in an _________ loop.
[A] finite
[B] infinite
[C] condition based
[D] unconditional
Answer : B
1065 A while is an __________
[A] selective construct
[B] unconditional statement
[C] loop construct
[D] conditional construct
Answer : C
1066 The minimum number of times the do-while loop executed is
[A] 0
[B] 1
[C] 2
[D] cannot be predicted
Answer : B
1067 The do-while loop is terminated when the conditional expression
returns
[A] zero
[B] 1
[C] non-zero
[D] -1
Answer : A
1068 Which of the following statements is correct?
[A] while loop can be nested
[B] while cannot be nested
one type of loop cannot be nested into another type
[C]
of loop
[D] for loop cannot be nested into while loop
Answer : A
1069 Which of the following is an infinite loop for int x =10?
while (1)
{
if (!(x ! = 10))
[A] continue;
- --
}
while (!0)
{
if (x = = 10)
[B] continue;
----
}
do
{
[C]
---
}while (!(x > 10));
while (x > 10)
[D] {---};
Answer :
D
1070 What is the output of the following code?
main( )
{
int x = 3;
while (x --)
{
int x = 100;
x --;
printf(“%d..”, x);
}
}
[A] infinite loop
[B] Error
[C] 99..99..99
[D] 3..2..1
Answer : C
1071 The process of detecting and correcting the errors in the program
is called as
[A] Correction
[B] Verification
[C] Debugging
[D] Error detection
Answer : C
1072 When is syntax errors in a program are found:
[A] During execution
[B] During compilation
[C] Before compilation
[D] After execution
Answer : B
1073 Which of the following does not lead to run time errors?
[A] Dividing by zero
[B] Square root of the negative number
[C] Logarithm of zero
[D] Exceeding the system dependent limits
Answer : C
1074 How many arithmetic operators are there?
[A] 5
[B] 6
[C] 3
[D] 4
Answer : A
1075 Which of the following is an arithmetic operator?
[A] <
[B] |
[C] ||
[D] +
Answer : D
1076 The value of – 14 % 3 is
[A] 2
[B] -2
[C] 4
[D] -4
Answer : B
1077 If x = 6.0 and y = 7.0 then the value of x / y is
[A] -0.857143
[B] 0.857143
[C] ± 0.857143
[D] 1
Answer : B
1078 The value of – 2.0 / 3.0 = _______
[A] 0.666667
[B] - 0.666667
[C] ± 0.666667
[D] 0
Answer : B
1079 When a function has no arguments and no return values
[A] it does not receive any data from the calling function
[B] it returns a value
[C] it receives data from the calling function
data transfer takes place between calling function and
[D]
the called function
Answer :
A
1080 When a function with arguments and no return values
it does not receive any data from the calling function
[A]
and returns a value
[B] it only returns a value
it receives data from the calling function and also
[C]
sends data to it
data transfer takes place between calling function and
[D]
the called function in one way
Answer :
D
1081 When a function with arguments and with return values
[A] it returns only one value
[B] it only passes some arguments
it is a two way communication between the calling
[C]
program and the function block
[D] it returns the arguments as values
Answer :
C
1082 The actual arguments cannot be
[A] a constant or a variable
[B] a different type from the formal arguments
[C] other functions
[D] expressions
Answer : B
1083 Parameters are used to
[A] return values from the called function
[B] return values from the calling function
[C] send values to the called function
[D] to specify the data type of the return value
Answer : C
1084 Which of the following is not passed to a function
[A] a constant
[B] a variable
[C] a structure
[D] a identifier
Answer : D
1085 When we pass array as a parameter to a function _____ is passed.
[A] first element is passed
[B] all elements are passed
[C] address of first element is passed
[D] error
Answer : C
1086 main()
{
int a, b, c = 0;
for (a = 1; a<=5; a ++)
{
b = f1(a++);
c=c+b;
}
printf(“%d”,c);
}
f1 (int b)
{
return ++b;
}
[A] 12
[B] 20
[C] 15
[D] 7
Answer : A
1087 main()
{
int a, b, c = 0;
for (a = 1; a<=5; a ++);
{
b = f1(a++);
c = c + b;
}
printf (“%d”, c);
}
f1 (int b)
{
return ++b;
}
[A] 12
[B] 20
[C] 15
[D] 7
Answer : D
1088 main()
{
int a = 5;
f1(a, ++a, a++);
}
f1 (int a, int b, int c)
{
printf(“%d%d%d”, a, b, c);
}
[A] 765
[B] 567
[C] 666
[D] 555
Answer : A
1089 main()
{
int a = 5;
f1(a, ++a, ++a);
}
f1 (int a, int b, int c)
{
printf(“%d%d%d”, a, b, c);
}
[A] 765
[B] 567
[C] 776
[D] 555
Answer : C
1090 main()
{
int a = 5;
f1(a- -, a, ++a);
}
f1 (int a, int b, int c)
{
printf(“%d%d%d”, a, b, c);
}
[A] 765
[B] 567
[C] 666
[D] 545
Answer : C
1091 main()
{
int a = 5;
f1(a- -, a, a);
}
f1 (int a, int b, int c)
{
printf(“%d%d%d”, a, b, c);
}
[A] 544
[B] 444
[C] 455
[D] 555
Answer : D
1092 main()
{
int a = 5, b = 6;
f1(a+b);
}
f1 (int a)
{
printf(“%d”, a);
}
[A] 11
[B] 5
[C] 6
[D] Error
Answer : A
1093 The program execution starts from
[A] the function which is first defined
[B] the main( ) function
[C] the function which is last defined
[D] the function other than main( )
Answer : B
1094 The data type that cannot be renamed by typedef is
[A] function
[B] structure
[C] pointer
[D] double
Answer : A
1095 How is a variable accessed from another file?
The global variable is referenced via the global
[A]
specifier
The global variable is referenced via the extern
[B]
specifier
The global variable is referenced via the auto
[C]
specifier
The global variable is referenced via the pointer
[D]
specifier
Answer : B
1096 Which of the following is/are achieved using typedef facility?
1. increase the portability of the code
2.write more compact code
[A] both the options 1 and 2
[B] only option 1
[C] only option 2
[D] neither option 1 nor option 2
Answer : A
1097 What does invoking the C compiler accomplish?
[A] It links together object files
[B] It creates machine code
It only provides code evaluation. You must use the
[C]
linker to assemble and link programs
[D] It interprets files at run time
Answer :
D
1098 The storage class allowed for parameters is
[A] auto
[B] static
[C] Extern
[D] register
Answer : D
1099 Functions are assigned by default
[A] auto storage class
[B] static storage class
[C] extern storage class
[D] register storage class
Answer : C
1100 The storage class specifiers are used to specify the ________ of
the variables within the program.
[A] scope
[B] value
[C] address
[D] data type
Answer : A
1101
#include
void func()
{
int x = 0;
static int y = 0;
x++; y++;
printf( "%d -- %d\n", x, y );
}
int main()
{
func();
func();
return 0;
}
What will the code above print when it is executed?
1-- 1
[A]
1–1
1 -- 1
[B]
1 -- 2
1 -- 1
[C]
2 -- 1
1 -- 0
[D]
1 -- 0
Answer : B
1102 The default value of the static and external variables is
[A] 00
[B] 10
[C] 01
[D] Garbage value Garbage value
Answer : A
1103 The default value of register and auto variables is
[A] 00
[B] 10
[C] 01
[D] Garbage value Garbage value
Answer : D
1104 The scope of the static and extern variable is
[A] local local
[B] local global
[C] global local
[D] global global
Answer : B
1105 The scope of register and auto variables is
[A] local local
[B] local global
[C] global local
[D] global global
Answer : A
1106 The scope of static and register variables is
[A] local local
[B] local global
[C] global local
[D] global global
Answer : A
1107 The scope of register and auto variables is
[A] local local
[B] local global
[C] global local
[D] global global
Answer : A
1108 The default value for static and register variables is
[A] 00
[B] 0 Garbage value
[C] Garbage value 0
[D] Garbage value Garbage value
Answer : B
1109 The default value for extern and autos variables is
[A] 00
[B] 0 Garbage value
[C] Garbage value 0
[D] Garbage value Garbage value
Answer : B
1110 char sub[10] = ????;
Which of the following statements cannot be used to replace
the ???? in the above syntax to initialize sub with the string “
Maths”?
[A] {“Maths”}
[B] {‘M’, ‘a’, ‘t’, ‘h’, ‘s’, ‘\0’}
[C] {‘M’ “aths”}
[D] {“Mat” “hs”}
Answer : C
1111 main()
{
char s1[100]; char s2[100];
gets(s1);
fgets (s2, sizeof(s2), stdin);
printf(“%d\n”, strlen(s1) – strlen(s2));
}
What will be printed when the above code is executed
and the string “abcd” is entered twice on stdin?
[A] -1
[B] 0
[C] 1
[D] 4
Answer : A
1112 A char array with the string value “aeiou” can be initialized as
[A] char s[] = {‘a’, ‘e’, ‘i’, ‘o’, ‘u’};
[B] char s[] = “aeiou”;
[C] char s[] = {‘a’, ‘e’, ‘i’ ,’o’, ‘u’, ‘\0’};
[D] options a and b
Answer : D
1113 main ()
{
char s[] = “Focal Point”;
printf(“%d\n”, ????);
}
Which of the following could replace the ???? in the
code above to print the index of the first occurrence
of the letter o in s (in this case the value would be
1)?
[A] strchr(s, ‘o’) – s
[B] strchr(s, “o”)
[C] strchr(s, ‘o’)
[D] strchr(s, “o”) – s
Answer : A
1114 Which of the following is false in case of external variable
declaration
[A] does not allocate memory
[B] cannot be initialized
[C] uses keyword extern
[D] allocates memory
Answer : D
1115 External variable does not require
[A] declaration
[B] keyword
[C] definition
[D] initialization
Answer : B
1116 Which of the following is false in case of external variable
declaration
[A] is specified outside main ( )
[B] reserves memory for storage
[C] is defined only once
[D] uses keyword
Answer : B
1117 The storage class specifier __________ is a recommendation to
the compiler to store a variable in one of the computers registers.
[A] register
[B] Auto
[C] scope
[D] function prototype
Answer : A
1118 A variable declared outside any block or function is called an
_____ variable.
[A] global
[B] external
[C] both a, b
[D] none
Answer : C
1119 For a local variable in a function to retain its value between calls
to the function, it must be declared with the _____ storage class
specifier.
[A] dynamic
[B] static
[C] auto
[D] none
Answer : B
1120 main()
{
printf("%d", out);
}
int out=100;
[A] Compiler error
[B] 100
[C] out
[D] no value
Answer : A
1121 main()
{
extern out;
printf("%d", out);
}
int out=100;
[A] 100
[B] out
[C] compiler error
[D] no value
Answer : A
1122 #include
main()
{
int x;
for (x = 1; x < = 3; x++)
fun();
}
fun( )
{
static int y = 0;
y = y + 1;
printf(“y = %d\n”, x);
}
The output of the above program is
[A] y=0
y=1
[B] y=1
y=1
1
[C] 2
3
y=1
[D] y=2
y=3
Answer : D
1123 #include
main()
{
int x;
for (x = 1; x < = 3; x++)
fun();
}
fun( )
{
int y = 0;
y = y + 1;
printf(“y = %d\n”, x);
}
The output of the above program is
[A] y=0
y=1
[B] y=1
y=1
1
[C] 2
3
y=1
[D] y=2
y=3
Answer : B
1124 What is the output?
main ()
{ int x = 80, a = -80;
void swap(int , int);
swap (x, a);
printf(“numbers are %d \t%d”, a, x);
}
void swap (int y, int b)
{
int t = y;
y = b;
b = t;
}
[A] numbers are 80 -80
[B] numbers are 80 80
[C] numbers are -80 80
[D] numbers are -80 -80
Answer : C
1125 main ()
{ int x = 80, a = -80;
void swap(int , int);
swap (x, a);
printf(“numbers are %d \t%d”, a, x);
}
void swap (int y, int b)
{
int t = y;
y = b;
b = t;
}
In the above code the formal parameters are
[A] x, y
[B] x, a
[C] a, b
[D] y, b
Answer : D
1126 main ()
{
int x = 80, a = -80;
void swap(int , int);
swap (x, a);
printf(“numbers are %d \t%d”, a, x);
}
void swap (int y, int b)
{
int t = y;
y = b;
b = t;
}
In the above code the actual parameters are
[A] x, y
[B] x, a
[C] a, b
[D] y, b
Answer : B
1127 main () { int x = 80, a = -80; void swap(int , int); swap (x, a);
printf(“numbers are %d \t%d”, a, x); } void swap (int y, int b) { int
t = y; y = b; b = t; } The value of a is stored in _________
parameter
[A] x
[B] y
[C] b
[D] t
Answer : B
1128 1 main ()
2 {
3 int x = 80, a = -80;
4 void swap(int , int);
5 swap (x, a);
6 printf(“numbers are %d \t%d”, a, x);
7 }
8 void swap (int y, int b)
9 {
10 int t = y;
11 y = b;
12 b = t;
13 }
The function prototype is in _______ line number
[A] 4
[B] 5
[C] 8
[D] 6
Answer : A
1129 1 main ()
2 {
3 int x = 80, a = -80;
4 void swap(int , int);
5 swap (x, a);
6 printf(“numbers are %d \t%d”, a, x);
7 }
8 void swap (int y, int b)
9 {
10 int t = y;
11 y = b;
12 b = t;
13 }
The function declaration is in _______ line number
[A] 4
[B] 5
[C] 8
[D] 6
Answer : A
1130 1 main ()
2 {
3 int x = 80, a = -80;
4 void swap(int , int);
5 swap (x, a);
6 printf(“numbers are %d \t%d”, a, x);
7 }
8 void swap (int y, int b)
9 {
10 int t = y;
11 y = b;
12 b = t;
13 }
The function call is in _______ line number
[A] 4
[B] 5
[C] 8
[D] 6
Answer : B
1131 1 main ()
2 {
3 int x = 80, a = -80;
4 void swap(int , int);
5 swap (x, a);
6 printf(“numbers are %d \t%d”, a, x);
7 }
8 void swap (int y, int b)
9 {
10 int t = y;
11 y = b;
12 b = t;
13 }
The function definition is in _______ line number
[A] 4
[B] 5
[C] 8
[D] 6
Answer : B
1132 What is the output generated ?
#include
main()
{
int a, b;
for (a = 1; a<=5; a ++)
{
b = sq(a);
printf(“%d”,b);
}
}
sq (int b)
{
return b * b;
}
[A] 1234567
[B] 2516941
[C] 9162514
[D] 1491625
Answer : D
1133 Which parameter of strcpy is destination?
[A] 0
[B] 1
[C] 2
[D] 3
Answer : B
1134 strcmp returns zero in __________ condition
[A] if two strings are not equal
[B] if two strings are equal
[C] if two characters are equal
[D] if two characters are not equal
Answer : B
1135 strcmp (“RAM”, “ram”) returns __________
[A] 0
[B] 32
[C] -32
[D] 1
Answer : B
1136 strcmpi (“RAM”, “ram”) returns __________
[A] 0
[B] 32
[C] -32
[D] 1
Answer : A
1137 The string related function supplied by C standard library is
[A] strlen( )
[B] toupper ( )
[C] tolower( )
[D] all of the above
Answer : A
1138 The function that is used to print the reverse of the string
[A] strlen()
[B] strcat()
[C] strcpy()
[D] strrev()
Answer : D
1139 The following function is used to count and return the number of
characters in a given string
[A] strcat()
[B] strlen()
[C] strcmp()
[D] strrev()
Answer : B
1140 Which of the following statements copies ‘Hello’ into string ‘a’
[A] strcpy(“Hello”, “Done”);
[B] strcpy(“Hello”, a);
[C] strcpy(a, “Hello”);
[D] strcpy(“Hello”, “Hello”);
Answer : C
1141 The input function scanf ( ) can be used with __________ format
specification to read in a string of characters
[A] %c
[B] %s
[C] %d
[D] %f
Answer : B
1142 We use generally ________ loop to copy the characters contained
inside one string in to the other
[A] goto
[B] for
[C] if
[D] switch
Answer : B
1143 For writing strings we use _________ function
[A] printf( )
[B] scan f( )
[C] read( )
[D] write( )
Answer : A
1144 For reading strings we use _________ function.
[A] printf( )
[B] scan f( )
[C] read( )
[D] write( )
Answer : B
1145 The printf( ) uses _________ format to print strings to the screen.
[A] %c
[B] %s
[C] %d
[D] %f
Answer : B
1146 char x[5][5];
The above array can store
[A] five strings each of length 4
[B] four strings each of length 4
[C] five strings each of length 5
[D] four strings each of length 5
Answer : C
1147 The ASCII value of ‘\0’ is
[A] 0
[B] 1
[C] 2
[D] 3
Answer : A
1148 ________ is called as string terminator
[A] character
[B] null character
[C] null string
[D] new line character
Answer : B
1149 Symbol of null character is
[A] 0
[B] ‘\0’
[C] ‘/0’
[D] ‘$0’
Answer : B
1150 The ______ function will display only one character on the screen.
[A] puts()
[B] putchar()
[C] gets()
[D] getchar()
Answer : B
1151 In C language the string is assigned to
[A] char type of variable
[B] string type of variable
[C] conversion specification %s
[D] integer type of variable
Answer : A
1152 The length of the string NEW DELHI is
[A] 9
[B] 10
[C] 8
[D] 7
Answer : A
1153 A string in C is ____of character
[A] structure
[B] list
[C] array
[D] function
Answer : C
1154 Which among these is true when declaring a character array that
holds a string?
The length of the array should be exactly same as that
[A]
of the string
The length of the array should be one more than the
[B]
original size of the string
The length of the array should be one less than the
[C]
original size of the string
[D] none of the above
Answer :
B
1155 char x[] = “Hello”;
char y[10];
for(int s = 0; x[s];s++)
y[s] = x[s];
What is the error in the above statements for copying
the contents of x into y?
[A] In the declaration x has no dimension
[B] In for loop condition is not proper
[C] ‘\0’ is not copied to y
[D] No error
Answer : C
1156 int a[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, x = 4;(
printf(“%d”, a[++x]);
What is the output?
[A] error
[B] 4
[C] 5
[D] 6
Answer : D
1157 int a[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, x = 4;
printf(“%d”, a[x++]);
What is the output?
[A] error
[B] 4
[C] 5
[D] 6
Answer : C
1158 int a[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, x = 4;
printf(“%d”, a[--x]);
What is the value of x?
[A] error
[B] 4
[C] 5
[D] 6
Answer : B
1159 int a[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, x = 4;
printf(“%d”, a[x--]);
What is the value of x?
[A] error
[B] 4
[C] 5
[D] 6
Answer : C
1160 If you declare an array of 100 elements the elements have index.
[A] 0 through 99
[B] 0 through 100
[C] 1 through 100
[D] 1 through 99
Answer : A
1161 The value with in the [ ] in an array declaration specifies
[A] subscript value
[B] index value
[C] size of an array
[D] value of an array element
Answer : C
1162 The lower index of an array is called _______
[A] upper bound
[B] lower bound
[C] minimum value
[D] minimum bound
Answer : B
1163 The highest index is called ______
[A] upper bound
[B] lower bound
[C] maximum value
[D] maximum bound
Answer : A
1164 What is the output of the following program?
#include
const int k = 100;
main()
{
int a [100]; int sum = 0;
for (k = 0; k < 100; k ++) * (a + k) = k;
sum+ = a [ --k];
printf(“%d”, sum);
}
[A] numbers from 1 to 100
[B] numbers from 100 to 1
[C] error in the loop
[D] error since const value k cannot be modified
Answer : D
1165 How can the word YES be stored in any array
[A] array[1] = 'Y'
array[2] = 'E'
array[3] = 'S'
array[4] = '\0'
array[0] = "Y"
array[1] = "E"
[B]
array[2] = "S"
array[3] = "\0"
array[1] = "Y"
[C] array[2] = "E"
array[3] = "S"
array[0] = 'Y'
array[1] = 'E'
[D]
array[2] = 'S'
array[3] = '\0'
Answer : D
1166 Array declaration
[A] requires the number of elements to be specified
does not require the number of elements to be
[B]
specified
[C] assumes default size as 0
[D] is not necessary
Answer : A
1167 If the size of an array is less than the number of initializes,
[A] the extra values are neglected
[B] it is an error
[C] the size is automatically increased
[D] the size is neglected
Answer : C
1168 Identify the correct statement
[A] float array can be read as a whole
[B] integer array can be read as a whole
[C] char array can be read as a whole
[D] Double array can be read as a whole
Answer : C
1169 Identify the correct statement
float array can be displayed by using single printf()
[A]
without using a loop
integer array can be displayed by using single printf()
[B]
without using a loop
char array can be displayed by using single printf()
[C]
without using a loop
[D] Double array can be displayed by using single printf()
without using a loop
Answer :
C
1170 Missing elements of partly initialized arrays are
[A] set to zero
[B] set to one
[C] not defined
[D] invalid
Answer : A
1171 When should an array be used?
[A] When we need to hold variable values
[B] When we need to data of the same type
When we need to obtain automatic memory cleanup
[C]
functionality
[D] When we need to hold data of different types
Answer :
B
1172 The value within the [ ] in an array variable specifies?
[A] subscript value
[B] size of the array
[C] value of the array element
[D] array bound
Answer : A
1173 A list of a finite number of similar data elements referenced
respectively by a set of n consecutive numbers is _________
[A] array
[B] linear array
[C] structure
[D] subscript
Answer : A
1174 If int occupies 2 bytes then in int a[10] size of a is _________
bytes
[A] 2
[B] 10
[C] 20
[D] 40
Answer : C
1175 int a [12] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
int i = 2;
printf(“%d”, i[a]); prints ___________ value.
[A] error
[B] garbage value
[C] 3
[D] address of second element
Answer : C
1176 Static int a[];
When the above statement is executed the contents of the array are
[A] garbage values
[B] zeros
[C] first element is zero
[D] error
Answer : D
1177 Array is used to represent
[A] a list of data items of integer data type
[B] a list of data items of real data type
[C] a list of data items of different data type
[D] a list of data items of same data type
Answer : D
1178 Array name is
[A] an array variable
[B] a keyword
[C] a common name shared by all elements
[D] not used in a program
Answer : C
1179 One dimensional array is known as
[A] vector
[B] table
[C] matrix
[D] an array of arrays
Answer : A
1180 The array elements occupy
[A] subsequent memory locations
[B] random location for each element
[C] varying length of memory locations for each element
[D] no space in memory
Answer : A
1181 The array elements are represented by
[A] index values
[B] subscripted variables
[C] array name
[D] size of an array
Answer : B
1182 The address of the starting element of an array is
represented by subscripted variable of the starting
[A]
element
[B] cannot be specified
[C] represented by the array name
[D] not used by the compiler
Answer : C
1183 Identify the wrong statement?
[A] Subscripts are also known as indices
[B] Array variables and subscripted variables are same
[C] Array name and subscripted variables are different
[D] Array name and subscripted variables are same
Answer : D
1184 Two-dimensional array elements are stored in
[A] column major order
[B] row major order
[C] random order
[D] in any order
Answer : B
1185 In a multi dimensional array with initialization
[A] the right most dimension may be omitted
[B] the left most dimension may be omitted
[C] nothing must be omitted
[D] All may be omitted
Answer : B
1186 Int a [3][4]
a[1] refers to
[A] error
[B] address of first element
[C] address of second row
[D] address of first row
Answer : C
1187 Int a [3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
printf(“%d”, a[1][2]); prints ___________ value.
[A] 7
[B] 4
[C] 5
[D] 6
Answer : A
1188 Int a [3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
printf(“%d”, a[2][2]); prints___________ value.
[A] 7
[B] 11
[C] 5
[D] 6
Answer : B
1189 Int a [3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
printf(“%d”, a); prints ___________ value.
[A] 1
[B] error
[C] address of array
[D] garbage value
Answer : C
1190 Int a [3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
printf(“%d”, a); prints ___________ value.
[A] 1
[B] error
[C] address of first element
[D] garbage value
Answer : C
1191 Int a [3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
printf(“%d”, &a); prints ___________ value.
[A] 1
[B] error
[C] address of array
[D] garbage value
Answer : C
1192 Int a [3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} printf(“%d”, &a
+ 1); prints ___________ value.
[A] error
[B] address of second row
[C] address of array
[D] address of second element
Answer : B
1193 Int a [3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} printf(“%d”,
&a[0] + 1); prints ___________ value.
[A] error
[B] address of second row
[C] address of array
[D] address of second element
Answer : D
1194 Int a [3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} printf(“%d”,
&a[0]); prints ___________ value.
[A] error
[B] address of second row
[C] address of array
[D] address of second element
Answer : C
1195 Int a [3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} printf (“%d”, a +
1); prints ___________ value.
[A] error
[B] address of second row
[C] address of array
[D] address of second element
Answer : B
1196 Static int a[5][5] ;
When the above statement is executed the contents of the array are
[A] garbage values
[B] zeros
[C] first element is zero
[D] first row is zero
Answer : B
1197 int a[5][5] ; When the above statement is executed the contents of
the array are
[A] garbage values
[B] zeros
[C] first element is zero
[D] first row is zero
Answer : A
1198 int booklet[3][2][2] = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
printf(“%d”, booklet[2][1][0]); What is the output?
[A] 5
[B] 7
[C] 9
[D] 11
Answer : D
1199 Consider that an integer occupies 4 bytes. Then size of integer
array with dimensions 11, 4 (a two dimensional array) would be:
[A] 60
[B] 176
[C] 48
[D] 120
Answer : B
1200 int a[3][3] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
Let base address of a is 65482
Printf(“%u”, &a);
What is the output?
[A] error
[B] 65482
[C] garbage value
[D] 1
Answer : B
1201 int a[3][3] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
Let base address of a is 65482
Printf(“%u”, a[0] );
What is the output?
[A] error
[B] 65482
[C] garbage value
[D] 1
Answer : B
1202 int a[3][3] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; Let base address of a is
65482 Printf(“%u”, &a[0][0] + 1); Let integer occupies 2 bytes.
What is the output?
[A] 65484
[B] 65482
[C] garbage value
[D] 1
Answer : A
1203 int a[3][3] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; Let base address of a is
65482 Printf(“%u”, a[0] + 1); Let integer occupies 2 bytes. What
is the output?
[A] 65484
[B] 65482
[C] garbage value
[D] 1
Answer : A
1204 int a[3][3] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; Let base address of a is
65482 Printf(“%u”, &a[0] + 1); Let integer occupies 2 bytes. What
is the output?
[A] 65484
[B] 65482
[C] 65488
[D] 65500
Answer : C
1205 int a[3][3] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; Let base address of a is
65482 Printf (“%u”, a + 1); Let integer occupies 2 bytes. What is
the output?
[A] 65484
[B] 65482
[C] 65488
[D] 65500
Answer : C
1206 int a[3][3] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; Let base address of a is
65482 Printf (“%u”, &a + 1); Let integer occupies 2 bytes. What is
the output?
[A] 65484
[B] 65482
[C] 65488
[D] 65500
Answer : D
1207 int a[3][3] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; Let base address of a is
65482 Printf (“%u”, a[0][0] + 1); Let integer occupies 2 bytes.
What is the output?
[A] 2
[B] 1
[C] 65488
[D] 65500
Answer : A
1208 An upper triangular array is an array in which
[A] the elements that are above the diagonal are zeros
[B] the elements that are below the diagonal are zeros
the elements in which all the elements in the array
[C]
are zeros
[D] a single element is zero above the diagonal
Answer : B
1209 An lower triangular array is an array in which
[A] the elements that are above the diagonal are zeros
[B] the elements that are below the diagonal are zeros
the elements in which all the elements in the array
[C]
are zeros
[D] a single element is zero above the diagonal
Answer :
A
1210 A strictly triangular array (upper or lower) is an array in which
[A] the elements that are above the diagonal are zeros
[B] the elements that are below the diagonal are zeros
the elements in which all the elements in the array
[C]
are zeros
[D] the elements of the diagonal are also zero
Answer :
D
1211 A sparse array is an array in which
[A] all the elements in the array are zero
[B] all the upper diagonal elements are zero
[C] all the lower diagonal elements are zero
[D] the majority of elements are zeros
Answer : D
1212 The output of the following program is
for (x = 0; x < N; x ++)
{
for (y = 0; y < N ; y ++)
a [x][y] = 0;
a [x][x] = 1;
}
[A] prints the matrix
[B] prints the N x N matrix
[C] prints the N x 2 matrix
[D] prints the 2 x N matrix
Answer : B
1213 The output of the following program is
for (x = 0; x < N; x ++)
{
for (y = 0; y < N ; y ++)
a [x][y] = 0;
a [x][x] = 1;
}
[A] prints the matrix
[B] prints the N x N matrix
[C] prints the N x 2 matrix
[D] prints the 2 x N matrix
Answer : B
1214 The automatic storage class has
[A] temporary storage
[B] automatic variable
[C] persistent storage
[D] file scope
Answer : A
1215 The register storage class has
[A] temporary storage
[B] automatic variable
[C] persistent storage
[D] file scope
Answer : A
1216 The storage class type of internal static has
[A] persistent storage
[B] file scope
[C] temporary storage
[D] automatic variable
Answer : A
1217 Which storage class may help in faster execution?
[A] static
[B] extern
[C] register
[D] auto
Answer : C
1218 Which storage class does not specify local variables?
[A] extern
[B] auto
[C] register
[D] internal static
Answer : A
1219 Which storage class does not specify global variables?
[A] extern
[B] external static
[C] typedef
[D] register
Answer : D
1220 External variable declaration uses
[A] the keyword external
[B] the keyword extern
[C] no keyword such as extern or external
[D] the keyword register
Answer : B
1221 External variable definition uses
[A] the keyword external
[B] the keyword extern
[C] no keyword
[D] the keyword auto
Answer : C
1222 External variable does not requires
[A] declaration
[B] definition
[C] initialization only
[D] keyword
Answer : D
1223 What does extern means in a function declaration?
[A] the function has global scope
[B] the function need not be defined
[C] nothing really
the function has local scope only to the file it is
[D]
defined in.
Answer : C
1224 Which of the following is false in case of external variable
definition
[A] creates a variable
[B] allocates memory
[C] does not use extern keyword
[D] does not allocate memory
Answer : D
1225 The ________ number of times function sq is called
#include
main()
{
int a, b;
for (a = 1; a<=5; a ++)
{
b = sq(a);
printf(“%d”,b);
}
}
sq (int b)
{
return b * b;
}
[A] 0
[B] 5
[C] 4
[D] 2
Answer : B
1226 #include
main()
{
int a, b;
for (a = 1; a<=5; a ++);
{
b = sq(a);
printf(“%d”,b);
}
}
sq (int b)
{
return b * b;
}
What is the output of the above program?
[A] 1234567
[B] 36
[C] 9162514
[D] 1491625
Answer : B
1227 #include
main()
{
int a, b;
for (a = 1; a<=5; a ++);
{ b = sq(a);
printf(“%d”,b);
}
}
sq (int b)
{
return b * b;
}
The number of times function sq is called is _____
[A] 0
[B] 5
[C] 1
[D] 2
Answer : C
1228 #define clrscr() 100
main()
{
clrscr();
printf("%d\n",clrscr());
}
[A] 100
[B] 100 100
[C] 10000
[D] no value
Answer : A
1229 While passing a two dimensional array as a parameter
number of rows and columns of 2D array must be
[A]
mentioned
[B] number of rows and columns of 2D array may not be
mentioned
[C] only number of rows must be mentioned
[D] only number of columns must be mentioned
Answer :
D
1230 ____ functions are predefined and are supplied along with the
compiler.
[A] library functions
[B] user defined functions
[C] built in functions
[D] recursive functions
Answer : C
1231 Function declaration always ends with
[A] semi colon
[B] does not any ending
[C] closing braces
[D] colon
Answer : A
1232 #include
main()
{
int a, b;
for (a = 1; a<=5; a ++);
b = sq(a);
printf(“%d%d”, a, b);
}
sq (int b)
{
b++;
return b ;
}
The output of the above program is _____
[A] 1, 2
[B] 5, 6
[C] 6, 7
[D] 4, 5
Answer : C
1233 #include
main()
{
int a, b;
for (a = 1; a<=5; a ++)
b = sq(a);
printf(“%d%d”, a, b);
}
sq (int b)
{
b++;
return b ;
}
The output of the above program is _____
[A] 1, 2
[B] 5, 6
[C] 6, 7
[D] 4, 5
Answer : B
1234 #include
main()
{
int a, b;
for (a = 1; a<=5; a ++)
b = sq(a);
printf(“%d%d”, a, b);
}
sq (int b)
{
int x;
for(x = 1;x <=b; x++)
b = b*x;
return b;
}
The output of the above program is _____
[A] 5, 120
[B] 6, 600
[C] 5, 600
[D] 6, 720
Answer : C
1235 #include
main()
{
int a, b;
for (a = 1; a<=5; a ++);
b = sq(a);
printf(“%d%d”, a, b);
}
sq (int b)
{
int x;
for(x = 1;x <=b; x++);
b = b*x;
return b;
}
The output of the above program is _____
[A] 5, 120
[B] 6, 36
[C] 5, 600
[D] 6, 720
Answer : B
1236 #include
main()
{
int a, b;
for (a = 1; a<=5; a ++);
b = sq(a);
printf(“%d%d”, a, b);
}
sq (int b)
{
int x;
for(x = 1;x <=b; x++)
b = b*x;
return b;
}
The output of the above program is _____
[A] 5, 120
[B] 6, 4320
[C] 5, 600
[D] 6, 720
Answer : B
1237 main()
{ int i = abc(10);
printf("%d\n",--i);
}
int abc(int i)
{
return(i+ +);
}
[A] 9
[B] 10
[C] 11
[D] 8
Answer : A
1238 In C which of the following statements are true about the way the
arguments are passed?
1. The order of evaluation of arguments is compiler dependent
2. Arguments are passed by reference
[A] both options 1 and 2
[B] only option 1
[C] only option 2
[D] neither option 1 nor 2
Answer : B
1239 The variables which are not used to transfer data between a sub
program and its calling program is ___
[A] parameters
[B] Global variables
[C] Local variables
[D] arguments
Answer : C
1240 The variables which can be accessed by all of the programs
modules in a computer program.
[A] local variables
[B] global variables
[C] parameters
[D] arguments
Answer : B
1241 Which of the following can legitimately be passed to a function?
[A] constant
[B] variable
[C] structure
[D] All
Answer : D
1242 The keyword __________ is used in a function header to indicate
that a function does not return a value or to indicate that a function
contains no parameters.
[A] void
[B] return
[C] scope
[D] auto
Answer : A
1243 The _________ allows the compiler to check the number, types
and order of the arguments passed to a function.
[A] void
[B] return
[C] scope
[D] function prototype
Answer : D
1244 Variables declared in a block or in the parameter list of a function
are assumed to be of storage class ______ unless specified.
[A] Rand
[B] Auto
[C] scope
[D] function prototype
Answer : B
1245 How many main ( ) functions can be defined in a C program?
[A] 1
[B] 2
[C] 3
[D] any number of times
Answer : A
1246 A function is identified by ___followed by open parenthesis
[A] a keyword
[B] an identifier other than keywords
[C] an identifier including keywords
[D] an operator
Answer : B
1247 A function with no action
[A] is an invalid function
[B] produces syntax errors
[C] is allowed and is known as dummy function
[D] returns zero
Answer : C
1248 Parameters are used
[A] to return values from the called function
[B] to accept values from the calling function
to exchange the values between calling function and
[C]
called function
[D] to specify the data type of the return value
Answer :
C
1249 Identify the correct statement
A function can be defined more than once in a
[A]
program
[B] function definition cannot appear in any order
[C] functions cannot be distributed in many files
one function cannot be defined within another
[D]
function definition
Answer :
D
1250 The default return data type in function definition is
[A] void
[B] int
[C] float
[D] char
Answer : B
1251 The parameters in the function call are
[A] actual parameters
[B] formal parameters
[C] dummy parameters
[D] optional
Answer : A
1252 The parameters in the function definition are
[A] actual parameters
[B] formal parameters
[C] dummy parameters
[D] optional
Answer : B
1253 The parameters passing mechanism used in C are
[A] call by function
[B] call by name
[C] call by value
[D] call by address
Answer : C
1254 The storage class that can precede return data type in function
declaration is
[A] extern
[B] intern
[C] register
[D] address
Answer : C
1255 Recursive calls return when
[A] a function calls itself
[B] a function calls another function
[C] a function is inside another function
[D] two functions are embedded in another function
Answer : A
1256 The main ( ) function calls in the C program
[A] allows recursive calls
[B] does not allow recursive calls
[C] is optional
[D] is a built in function
Answer : A
1257 The function main( ) is
[A] a built in function
[B] a user defined function
[C] optional
[D] recursive function
Answer : B
1258 The storage class allowed for parameters is
[A] auto
[B] static
[C] extern
[D] register
Answer : D
1259 Functions are assigned by default
[A] auto storage class
[B] static storage class
[C] extern storage class
[D] register storage class
Answer : C
1260 Functions have
[A] file scope
[B] local scope
[C] block scope
[D] function scope
Answer : A
1261 The function defined in math.h file for returning the arc tangent of
x is
[A] tan_1(x)
[B] a tan(x)
[C] tanh(x)
[D] arctan(x)
Answer : B
1262 The function ceil (x) defined in math.h
returns the value rounded down to the next lower
[A]
integer
returns the value rounded down to the next higher
[B]
integer
[C] the next higher value
[D] the next lower value
Answer : B
1263 The function floor(x) defined in math.h
returns the value rounded down to the next lower
[A]
integer
returns the value rounded down to the next higher
[B]
integer
[C] the next higher value
[D] the next lower value
Answer : A
1264 What function must all C programs have?
[A] start ( )
[B] main( )
[C] return ( )
[D] exit ()
Answer : B
1265 Which of the following statements in C are true? 1. Two functions
can have the same name in a single program 2. Function calls can
be recursive
[A] both options 1 and 2
[B] only option 1
[C] only option 2
[D] neither option 1 nor 2
Answer : C
1266 Which of the following would compute the square of x in C?
[A] pow(2, x)
[B] pow(x, 2)
[C] x ** 2
[D] power(x, 2)
Answer : B
1267 All standard C library functions return what data type?
[A] decimal
[B] float
[C] double
[D] int
Answer : C
1268 The variables which can be accessed only with in a particular
program or sub program are ___
[A] parameters
[B] Global variables
[C] Local variables
[D] arguments
Answer : C
1269 Through return statement _______ number of values can be
returned
[A] 1
[B] 2
[C] 3
[D] 4
Answer : A
1270 _________ cannot be returned through return statement
[A] integer
[B] string
[C] array
[D] structure
Answer : C
1271 For a local variable in a function to retain its value between calls
to the function, it must be declared with _______ storage class
specifier.
[A] dynamic
[B] fixed
[C] static
[D] none
Answer : C
1272 A function which calls itself directly or indirectly again and again
is known as the
[A] Recursive function
[B] public function
[C] private function
[D] protected function
Answer : A
1273 A function is invoked by
[A] function name
[B] function class
[C] function call
[D] arguments of the function
Answer : C
1274 The ______ statement in a called function is used to pass the value
of an expression back to the calling function.
[A] void
[B] return
[C] scope
[D] auto
Answer : B
1275 The _______ qualifier is used to declare read only variables.
[A] variable
[B] constant
[C] var
[D] const
Answer : D
1276 A function that does not return anything has return type _______
[A] scope
[B] void
[C] declaratory
[D] none
Answer : B
1277 A function can
[A] perform a task
[B] return a value
change value of actual arguments in call by
[C]
reference
[D] all of the above
Answer : D
1278 Which of the following statements is TRUE with respect to
function declaration?
[A] Prototype is required for all functions
[B] Prototype is not required for all functions
[C] Prototype is required for functions returning integers
[D] Prototype is required for functions returning pointers
Answer : D
1279 ________ statement causes an immediate exit from the function
and to give a value.
[A] Break
[B] Exit
[C] Return
[D] Continue
Answer : C
1280 The program execution starts from
[A] the function which is first defined
[B] main() function
[C] the function which is last defined
[D] the function which comes first in the main ()
Answer : B
1281 What is true about the following C Functions
[A] Need not return any value
[B] Should always return an integer
[C] Should always return a float
[D] Should always return more than one value
Answer : A
1282 Which of the following about automatic variables within a
function is correct?
[A] Its type must be declared before using the variable
[B] They are local
[C] They are not initialized to zero
[D] They are global
Answer : C
1283 Write one statement equivalent to the following two statements
x=sqr(a);
return(x);
Choose from one of the alternatives
[A] return(sqr(a));
[B] printf("sqr(a)");
[C] return(a*a*a);
[D] printf("%d",sqr(a));
Answer : A
1284 Storage class does not control
[A] life time of a variable
[B] scope of a variable
[C] linkage of a variable
[D] block scope
Answer : D
1285 Longevity of a variable refers to
the duration for which the variable retains the given
[A]
value during the execution of the program
the portion of a program in which the variable may be
[B]
visible
[C] internal linkage of a variable
[D] external linkage of a variable
Answer :
A
1286 Scope of a variable refers to
the duration for which the variable retains a given
[A]
value during the execution of a program
the portion of a program in which the variable may be
[B]
visible
[C] the value of the variable
[D] linkage of the variable
Answer :
B
1287 A variable with external linkage refers to
the duration for which the variable retains a given
[A]
value during the execution of a program
the same value for every occurrence of that variable in
[B]
a particular file
the Same value in every source file where source
[C]
program spans over multiple files
[D] block scope
Answer :
C
1288 A variable with internal linkage refers to
the duration for which the variable retains a given
[A]
value during the execution of a program
the same value for every occurrence of that variable in
[B]
a particular file
the Same value in every source file where source
[C]
program spans over multiple files
[D] block scope
Answer :
B
1289 A variable with no linkage refers to
the duration for which the variable retains a given
[A]
value during the execution of a program
the same value for every occurrence of that variable in
[B]
a particular file
the Same value in every source file where source
[C]
program spans over multiple files
[D] block scope
Answer :
D
1290 Which is not a storage class?
[A] auto
[B] struct
[C] static
[D] extern
Answer : B
1291 The typedef statement is used to
[A] create a new data type
[B] rename the existing data type
[C] to define a storage class
[D] create a structure
Answer : B
1292 Identify the correct statement?
[A] typedef int HOST
[B] typedef int HOST;
[C] typedef int = HOST
[D] typedef int = HOST;
Answer : B
1293 The typedef statement does not
[A] create new data type
[B] backward refer
[C] rename the data type
[D] reserves memory for storage
Answer : A
1294 If the definition of an external variable does not contain an
initializer it is known as
[A] forward declaration
[B] tentative declaration
[C] backward reference
[D] backward definition
Answer : B
1295 main ()
{
char s[6] = “HELLO”;
printf(“%s”, s[5]);
}
What is the output of the above program?
[A] 0
[B] 48
[C] nothing
[D] unpredictable
Answer : C
1296 char name [] = {‘n’, ‘a’, ‘m’, ‘e’};
printf(“name = %s\n”, name);
What will be the output?
[A] name = name
[B] name = name followed by junk characters
[C] name = \nname
[D] option a or b
Answer : B
1297 What would be the result of the following program?
main( )
{char p[] = “string”;
char t;
int x, y;
for (x = 0, y = strlen(p); x < y; x + +)
{
t = p[x];
p[x] = p[y – x];
p[y – x] = t;
}
printf(“%s”, p);
}
[A] will print: string
will not print anything since p will be pointing to a
[B]
null string
[C] will print:gnirts
[D] will result in a complication error
Answer :
B
1298 char x [] = “Hello”;
if character occupies 1 byte size of x is
[A] error
[B] 5
[C] 6
[D] 1
Answer : C
1299 If we want to store a string of n characters then we require an
array of ____ size?
[A] n
[B] 10
[C] n+1
[D] garbage
Answer : C
1300 char x [] = “HELLO”;
printf(“%d”, x[5]);
What is the output?
[A] error
[B] 79
[C] 6
[D] 0
Answer : D
1301 char x [] = “Hello”;
printf(“%d”, strlen (x));
What is the output?
[A] error
[B] 5
[C] 6
[D] 1
Answer : B
1302 char x [] = “Hello”;
printf(“%d”, x[strlen (x)]);
What is the output?
[A] error
[B] 5
[C] 6
[D] 0
Answer : D
1303 Char x[10] = “ GOOD”;
Char y[10] = “HELLO”;
Strcpy (x, y);
The contents of x and y are
[A] GOOD GOOD
[B] HELLO HELLO
[C] GOOD HELLO
[D] HELLO GOOD
Answer : B
1304 Char x[10] = “ GOOD”;
Char y[10] = “HELLO”;
Strcat (x, y);
The contents of x and y are
[A] GOODGOOD, HELLO
[B] HELLOHELLO, GOOD
[C] GOODHELLO, HELLO
[D] HELLOGOOD, HELLO
Answer : C
1305 Char x[10] = “ GOOD”;
Char y[10] = “HELLO”;
x [0] = y[4];
printf(“%s”, x);
[A] GOOD
[B] HOOD
[C] OOOD
[D] Null
Answer : C
1306 Char x[10] = “ GOOD”;
Char y[10] = “HELLO”;
x [0] = y[5];
printf(“%s”, x);
[A] GOOD
[B] HOOD
[C] OOOD
[D] Null
Answer : D
1307 static char city[][] = {“Chandigarh”, “Madras”, Ahmedabad”,
“Hyderabad”, “Bombay”}; If char occupies 1 byte then size of city
is
[A] 40
[B] 45
[C] 55
[D] 50
Answer : C
1308 static char city[][] = {“Chandigarh”, “Madras”, Ahmedabad”,
“Hyderabad”, “Bombay”};
printf(“%s”, city[2] ); prints
[A] error
[B] andigarh
[C] Ahmedabad
[D] Madras
Answer : C
1309 static char city[][] = {“Chandigarh”, “Madras”, Ahmedabad”,
“Hyderabad”, “Bombay”};
printf(“%s”, city[0][2] );
prints
[A] error
[B] andigarh
[C] Ahmedabad
[D] Madras
Answer : B
1310 static char city[][] = {“Chandigarh”, “Madras”, Ahmedabad”,
“Hyderabad”, “Bombay”};
printf(“%c”, city[0][2] );
prints
[A] error
[B] andigarh
[C] Ahmedabad
[D] a
Answer : D
1311 char x[] = “hello”;
printf( “%d”, x[0] – x[1] );
What is the output?
[A] garbage value
[B] error
[C] 0
[D] 3
Answer : D
1312 char x[] = “hello”;
printf( “%d”, x[2] – x[3] );
What is the output?
[A] garbage value
[B] error
[C] 0
[D] 3
Answer : C
1313 What is the output of the below program?
main()
{
char name;
name = ‘x’ ;
putchar (name);
}
[A] name
[B] x
[C] ‘x’
[D] “x”
Answer : B
1314 #include
main()
{
register i=5;
char j[]= "hello";
printf("%s %d",j,i);
}
[A] hello 5
[B] 5 hello
[C] hello hello
[D] 55
Answer : A
1315 void main()
{
char a[]="12345\0";
int i=strlen(a);
printf("here in 3 %d\n",++i);
}
[A] here in 3 6
[B] here in 3
[C] 12345
[D] 6
Answer : A
1316 The function strcpy(s1, s2) in string.h
[A] copies s1 to s2
[B] copies s2 to s1
[C] appends s1 to the end of s2
[D] appends s2 to the end of s1
Answer : B
1317 The function strcat(s1, s2) in string.h
[A] copies s1 to s2
[B] copies s2 to s1
[C] appends s1 to the end of s2
[D] appends s2 to the end of s1
Answer : D
1318 The function strcmp(s1, s2) returns zero
[A] if s1 is lexicographically less than s2
[B] if s1 is lexicographically greater than s2
[C] if both s1 and s2 are equal
[D] if s1 is empty string
Answer : C
1319 The function toupper(ch) in ctype.h
[A] returns the uppercase alphabet ch
[B] returns the lower case alphabet ch
returns uppercase if ch is lower case, and lower case
[C]
if ch is uppercase
[D] is a user defined function
Answer :
A
1320 The function tolower(ch) in ctype.h
[A] returns the uppercase alphabet ch
[B] returns the lower case alphabet ch
returns uppercase if ch is lower case, and lower case
[C]
if ch is uppercase
[D] is a user defined function
Answer :
B
1321 The string function strcat( )
[A] concatenates two strings
[B] compares two strings
[C] copies one string over the other
[D] finds the length over the other
Answer : A
1322 The string function strcmp( )
[A] concatenates two strings
[B] compares two strings
[C] copies one string over the other
[D] finds the length over the other
Answer : B
1323 The string function strcpy( )
[A] concatenates two strings
[B] compares two strings
[C] copies one string over the other
[D] finds the length over the other
Answer : C
1324 The string function strlen( )
[A] concatenates two strings
[B] compares two strings
[C] copies one string over the other
[D] finds the length over the other
Answer : D
1325 The string related function supplied by C standard library is
[A] strcpy( )
[B] strcat ( )
[C] strcmp ( )
[D] all of the above
Answer : D
1326 strcpy has _______ number of parameters
[A] 0
[B] 1
[C] 2
[D] 3
Answer : C
1327 Which parameter of strcpy is source?
[A] 0
[B] 1
[C] 2
[D] 3
Answer : C
1328 char x[20];
scan f(“%s”, x);
printf(“%s”, x);
When the above code is executed and “NEW DELHI” is entered
from the key board the output is _____
[A] NEW DELHI
[B] Error
[C] NEW
[D] DELHI
Answer : C
1329 char x[20];
gets(x);
printf(“%s”, x);
When the above code is executed and “NEW DELHI” is entered
from the key board the output is _____
[A] NEW DELHI
[B] Error
[C] NEW
[D] DELHI
Answer : A
1330 To read multiple words from the key board ____ input function is
used.
[A] scanf()
[B] read()
[C] gets()
[D] getchar()
Answer : C
1331 Which of the following statement is TRUE?
[A] Delimiter for scanf() is space only
[B] Delimiter for scanf() is Enter key only
[C] Delimiter for gets() is space only
[D] Delimiter for gets() is Enter key only
Answer : D
1332 Which of the following input functions will echo’s the input onto
the screen?
[A] getchar()
[B] getch()
[C] getche()
[D] gets()
Answer : C
1333 What is the output of the following program?
#include
const int k = 100;
main()
{
int a [100]; int sum = 0;
for (k = 0; k < 100; k ++) * (a + k) = k;
sum+ = a [ --k];
printf(“%d”, sum);
}
[A] numbers from 1 to 100
[B] numbers from 100 to 1
[C] error in the loop
[D] error since const value k cannot be modified
Answer : D
1334 What would be the output of the following program ?
Main ( )
{
static int a [20]
int i = 0;
a[i] = i++;
printf (“\n%d%d%d”, a[0], a[1],i);
}
[A] 010
[B] 001
[C] 100
[D] 101
Answer : B
1335 int a[9] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
for (i = 0; i < 6; i = i + 2)
a[i+2] = a[i];
What is the contents of a after this program fragment
executes?
[A] 010123456
[B] 234567878
[C] 2 3 4 5 6 7 8 9 10
[D] 010305078
Answer : D
1336 What would be the output of the following programs ?
Main ( )
{
int arr [ ] = { 12, 13, 14,15, 16};
print f (“ \ n %d %d %d”, size of (arr), size of (* arr ), size of
(arr[o] ) ) ;
}
[A] 2, 2, 2
[B] 10, 2, 2
[C] 2, 10, 2
[D] 4, 2
Answer : B
1337 Suppose the array begins at address 1500, then what would be
output of the following program ?
Main ( )
{
int a [ ] = { 4,5,1,2,3,7};
print f (“ %d” , size of (a) ) ;
}
[A] 15, 12
[B] 12
[C] 1500
[D] 2
Answer : B
1338 Suppose the array begins at address 1200, then the output of the
following program :
Main ( )
{ int x [ ] = { 1,2,3,4};
print f (“ %d, x + size of (x));
}
[A] 1202
[B] 8
[C] 1208
[D] 1210
Answer : C
1339 What is the output of the following program, if the array begins at
address 65486?
Main ( )
{
int x [ ] = { 10, 15, 20, 1, 0};
print f (“ %u %u”, x, &x);
}
[A] 65486, 65486
[B] 65486, 2
[C] 10, 65486
[D] 10, 2
Answer : A
1340 What would be the output of the following program ?
Main ( )
{
char x [ ] = “Sir “;
char y [ ] = “Sir “;
if (x = = y)
print f ( “ Equal “);
else
print f ( “ Unequal”)
}
[A] Equal
[B] Unequal
[C] Error
[D] None of the above
Answer : B
1341 Main ( )
{
print f(“ % c”, “abcd” [ 2 ] );
}
[A] Error
[B] B
[C] C
[D] D
Answer : C
1342 What would be the output of the following program ?
Main ( )
{
int a [5] = {2,3};
printf ( “\n%d %d %d”, a[2], a[3], a[4] ) ;
}
[A] Garbage values
[B] 2, 3, 3
[C] 3, 2, 2
[D] 0, 0, 0
Answer : A
1343 What would be the output of the following program?
main()
{
int arr[] = {12,13,14,15,16}
printf(“\n%d%d%d”, size of (arr), size of (*arr),
size of (arr[0] ));
}
[A] 2,210
[B] 2,10,10
[C] 2,2,2
[D] 2,4,10
Answer : A
1344 What will be the output of the following program
main()
{
int sub[50],i;
for(i=0,i<=48;i++);
{
sub[i]=i;
printf(“\n%d”,sub[i]);
}
}
[A] prints 0 to 48
[B] 0
[C] 0 to 47
[D] None of the above
Answer : D
1345 What will happen it you put too few elements in an array when
you initialize it
[A] nothing
[B] possible system malfunction
[C] error ménage form the compiler
[D] unused elements will be filled with 0’s or garbage
Answer : D
1346 What would be the output of the following program assume that
the begins at location 1002?
main()
{
int a[3][4] = {
1,2,3,4,
5,6,7,8,
9,10,11,12
};
printf(“\n%u%u%u”,
a[0]+1,*(a[0]+1),*(*(a+0)+1));
}
[A] 1002,1,2
[B] 1004,2,2
[C] 1004,2,1
[D] None of the above
Answer : B
1347 In three dimensional arrays the outer array has ____ elements
[A] 9
[B] 2
[C] 3
[D] 6
Answer : C
1348 #include
void inc_count (int count)
{
Count ++;
}
int main()
{
int count = 0; /* number of times through */
while (count < 10)
inc_count(count);
return count ;
}
What will be the value returned by the function
main?
[A] 0
[B] 10
[C] 9
[D] Null
Answer : A
1349 #include
void func()
{
int x = 0;
static int y = 0;
x++; y++;
printf( "%d -- %d\n", x, y );
}
int main()
{
Func();
func ();
return 0;
}
What will the code above print when it is
executed?
1—1
[A]
1 --1
1 -- 1
[B]
1 -- 2
1 -- 1
[C]
2 -- 1
1 -- 0
[D]
1 -- 0
Answer : B
1350 What does the following function print? func(int i) { if(i%2)return
0; else return 1;} main() { int =3; i=func(i); i=func(i);
printf("%d",i); }
[A] 3
[B] 1
[C] 0
[D] 2
Answer : B
1351 Main ( )
{
const int x = get ( );
print f (“ %d”, x );
}
get ( )
{
return (20);
}
[A] 20
[B] Garbage value
[C] Error
[D] 0
Answer : A
1352 What would be the output of the following program ?
#define CUBE(x) (x* x* x)
main ( )
{
int a,b = 3;
a = CUBE (b++);
printf ( “\n%d%d”, a,b);
}
[A] 27
[B] 64
[C] 4
[D] 3
Answer : B
1353 What is true about the following C Functions
[A] Need not return any value
[B] Should always return an integer
[C] Should always return a float
[D] Should always return more than one value
Answer : A
1354 Main must be written as
[A] The first function in the program
[B] Second function in the program
[C] Last function in the program
[D] Any where in the program
Answer : D
1355 In the following code in which order the functions would be called
?
a = f1(23,14) *12(12/4) + f3( );
[A] f1, f2, f3
[B] f3, f2, f1
[C] The order may vary from compiler to compiler
[D] None of the above
Answer : A
1356 What error would the following function give on
compilation ?
f ( int a, int b)
{
int a;
a = 20;
return a;
}
[A] Missing parentheses in return statement
[B] The function should be defined as int f ( int a, int b )
[C] Re declaration of a
[D] None of the above
Answer : C
1357 For n=2 the following fn returning value is
int fun(int n)
{
int sum=0;
for(i = 1;i < = n; i + +)
for(j = i; j < = i; j + +)
sum = sum + j;
return(sum);
}
[A] 5
[B] 6
[C] 3
[D] 4
Answer : C
1358 For x = 2, y = 3, z = 1
the following function return
int fun(int x; int y; int z)
{
int sum = 0;
for(i = x; i < = y; i + +)
for(j = 1; j < = z; z + +)
sum = sum + z;
return sum;
}
[A] 2
[B] 3
[C] 4
[D] 5
Answer : A
1359 For x=0 y=0 z=1
the following function return
int fun(int x; int y; int z)
{
int sum=0;
for(i = x; i < = y; i + +)
for(j = 1; j < = z; z + +)
sum = sum + z;
return sum;
}
[A] 2
[B] 3
[C] 1
[D] 5
Answer : C
1360 int term (int x)
{
int sum = 0; int i;
for(i = 0;i < = 5; i + +)
sum + = x;
return(sum);
}
the above function value for x = 150
[A] 650
[B] 900
[C] 750
[D] 600
Answer : B
1361 C program code
int zap(int n)
{
if(n<=1)then zap=1;
else zap=zap(n-3)+zap(n-1);
}
then the call zap(6) gives the values of zap
[A] 8
[B] 9
[C] 6
[D] 12
Answer : B
1362 Write one statement equivalent to the following two statements
x=sqr(a);
return(x);
Choose from one of the alternatives
[A] return(sqr(a));
[B] printf("sqr(a)");
[C] return(a*a*a);
[D] printf("%d",sqr(a));
Answer : A
1363 Which of the following about automatic variables within a
function is correct?
[A] Its type must be declared before using the variable
[B] They are local
[C] They are not initialized to zero
[D] They are global
Answer : A
1364 Regarding the scope of the varibles;identify the incorrect
statement:
[A] automatic variables are automatically initialized to 0
[B] static variables are automatically initialized to 0
[C] the address of a register variable is not accessible
static variables cannot be initialized with any
[D]
expression
Answer : A
1365 Which storage class for only these variables, which are being used
very often in a program
[A] Static
[B] Alto
[C] Extern
[D] Register
Answer : D
1366 Which storage class is used for only those variables which are
being used by almost all the functions in the program.
[A] static
[B] auto
[C] register
[D] extern
Answer : D
1367 If you want the value of a variable to persist between different
function calls
[A] static
[B] register
[C] extern
[D] auto
Answer : A
1368 What would be the output of the following program ?
Main ( )
{
extern int I;
i = 20;
printf ( “%d”,size of (i));
}
[A] 2
[B] 4
[C] would vary from compiler to compiler
[D] Error, i undefined
Answer : A
1369 What would be the output of the following program ?
Main ( )
{
extern int a;
printf ( “ \n%d”, a);
}
int a = 20;
[A] 20
[B] 0
[C] Garbage value
[D] Error
Answer : A
1370 Suppose that x and y are two strings. Which expression will return
true whenever x and y contain the same sequence of characters?
[A] (x = y)
[B] (x == y)
[C] (x != y)
[D] (strcmp(x, y))
Answer : D
1371 What would be the output of the following program?
main()
{
char str1[] = “Hello”;
char str2[] = “Hello”;
If (str1 = = str2)
Printf (“\n Equal”);
Else
}
[A] Equal
[B] Not equal
[C] Error
[D] None of the above
Answer : B
1372 Which one of the following function not standard string library
function
[A] Strnicmp
[B] Strdyp
[C] Strnset
[D] Strstrr
Answer : D
1373 char str[6];
strcpy(str, "BLACK");
strcpy(str, "RED);
What are the values of str[3], str[4], str[5] after
the two calls to strcpy?
[A] ’\0’, ’\0’, ’\0’
[B] ’\ 0 ’, ’K ’, ’\ 0 ’
[C] ’C ’, ’K ’, ’\ 0 ’
[D] ’C ’, ’K ’, ’R ’
Answer : B
1374 Main ( )
{
char x = ‘A’;
print f (“ % d % d”, size of (x), size of
(‘A’)) ;
}
[A] 1, 1
[B] 1, 2
[C] 2, 2
[D] 2, 1
Answer : B
1375 Array subscripts in C always starts with
[A] -1
[B] 0
[C] 1
[D] any value
Answer : B
1376 Maximum number of elements in the array declaration int x[10]; is
[A] 9
[B] 10
[C] 11
[D] undefined
Answer : B
1377 Array declaration
[A] requires the number of elements to be specified
does not require the number of elements to be
[B]
specified
[C] assumes default size as 0
[D] is not necessary
Answer : A
1378 If the size of an array is less than the number of initializes
[A] e extra values are neglected
[B] it is an error
[C] e size is automatically increased
[D] e size is neglected
Answer : B
1379 Identify the correct statement
[A] float array can be read as a whole
[B] integer array can be read as a whole
[C] char array can be read as a whole
[D] Double array can be read as a whole
Answer : C
1380 Identify the correct statement
float array can be displayed by using single printf()
[A]
without using a loop
integer array can be displayed by using single printf()
[B]
without using a loop
char array can be displayed by using single printf()
[C]
without using a loop
Double array can be displayed by using single printf()
[D]
without using a loop
Answer :
C
1381 Missing elements of partly initialized arrays are
[A] set to zero
[B] set to one
[C] not defined
[D] invalid
Answer : A
1382 When should an array be used?
[A] When we need to hold variable values
[B] When we need to hold data of the same type
When we need to obtain automatic memory cleanup
[C]
functionality
[D] When we need to hold data of different types
Answer :
B
1383 The value within the [ ] in an array variable specifies?
[A] subscript value
[B] size of the array
[C] value of the array element
[D] array bound
Answer : A
1384 A list of a finite number of similar data elements referenced
respectively by a set of n consecutive numbers is _________
[A] array
[B] linear array
[C] structure
[D] subscript
Answer : A
1385 If int occupies 2 bytes then in int a[10] size of a is _________
bytes
[A] 2
[B] 10
[C] 20
[D] 40
Answer : C
1386 int a [12] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
int i = 2;
printf(“%d”, i[a]); prints ___________ value.
[A] error
[B] garbage value
[C] 3
[D] address of second element
Answer : C
1387 Static int a[];
When the above statement is executed the contents of the array are
[A] garbage values
[B] zeros
[C] first element is zero
[D] error
Answer : D
1388 Static int a[] = { 1, 2, 3} ;
When the above statement is executed the size of array is ______
bytes if int occupies 2 bytes
[A] error
[B] 0
[C] 3
[D] 6
Answer : D
1389 Static int a[] ;
When the above statement is executed the size of array is ____
bytes if int occupies 2 bytes.
[A] error
[B] 0
[C] 3
[D] 6
Answer : A
1390 To read the values into an array minimum number of loops
required are _______
[A] 0
[B] 1
[C] 2
[D] 3
Answer : B
1391 int a[6], x;
for (x = 1; x <= 5; x++)
a[x] = x;
________ value is stored in a[0]
[A] 0
[B] garbage value
[C] 5
[D] 6
Answer : B
1392 Subscripted variables can be ________
[A] integer only
[B] float
[C] string
[D] pointer
Answer : A
1393 int n = 5;
int a[n] = {1, 2, 3, 4, 5}
printf(“%d”, a[0]);
What is the output?
[A] 1
[B] 5
[C] error
[D] garbage value
Answer : C
1394 const int n = 5;
int a[n] = {1, 2, 3, 4, 5}
printf(“%d”, a[0]);
What is the output?
[A] 1
[B] 5
[C] error
[D] garbage value
Answer : A
1395 #define n 5
int a[n] = {1, 2, 3, 4, 5}
printf(“%d”, a[0]);
What is the output?
[A] 1
[B] 5
[C] error
[D] garbage value
Answer : A
1396 int a[10], x;
for(x = 1; x < 10; x + +)
{
if (x % 3)
a[x] = x;
}
if the above code is executed, array contains
________ number of garbage values
[A] 0
[B] 10
[C] 3
[D] 4
Answer : D
1397 What is the output of the following program?
#include
const int k = 100;
main()
{
int a [100]; int sum = 0;
for (k = 0; k < 100; k ++) * (a + k) = k;
sum+ = a [ --k];
printf(“%d”, sum);
}
[A] numbers from 1 to 100
[B] numbers from 100 to 1
[C] error in the loop
[D] error since const value k cannot be modified
Answer : D
1398 Identify the correct declaration
[A] int a[10] [10];
[B] int a[10 , 10];
[C] int a(10) (10);
[D] int a(10,10);
Answer : A
1399 Maximum number of elements in the array declaration int x[5][8];
is
[A] 28
[B] 40
[C] 32
[D] 35
Answer : B
1400 The fseek feature
[A] Needs two arguments
[B] Makes the rewind feature unnecessary
Is meant for checking whether a given file exists or
[C]
not
[D] Need no arguments
Answer : B
1401 enum x {a=1,b,c,d,f=60,y};
printf("%d",y);
What is the value of y?
[A] 5
[B] 61
[C] 6
[D] 6
Answer : B
1402 struct {
int len;
char *str
}*p;
++p -> len;
The above program shows?
[A] increments p
[B] increments len
[C] compilation error
[D] nothing happens with either of p and len
Answer : B
1403 enum day { jan = 1 ,feb=4, april, may};
What is the value of may?
[A] 4
[B] 5
[C] 6
[D] 11
Answer : C
1404 struct a{
int x;
float y;
char c[10];
};
union b{
int x;
float y;
char c[10];
};
Which is true?
[A] sizeof(a)!=sizeof(b);
[B] sizeof(a)=sizeof(b);
[C] compilation error
[D] run time error
Answer : A
1405 struct code
{
int i;
int t;
}
/* some code */
main()
{}
What is wrong ?