Question No: 1 ( Marks: 1 ) - Please choose one
A precise sequence of steps to solve a problem is called
► Statement
► Program
► Utility
► Routine
Question No: 2 ( Marks: 1 ) - Please choose one
The Compiler of C language is written in
► Java Language
► UNIX
► FORTRON Language
► C Language
The C language is so powerful that the compiler of C and other various operating systems are written in C.
Question No: 3 ( Marks: 1 ) - Please choose one
Initialization of variable at the time of definition is,
► Must
► Necessary
► Good Programming
► None of the given options
Question No: 4 ( Marks: 1 ) - Please choose one
In if structure the block of statements is executed only,
► When the condition is false
► When it contain arithmetic operators
► When it contain logical operators
► When the condition is true
Question No: 5 ( Marks: 1 ) - Please choose one
Which of the following function(s) is/are included in stdlib.h header file?
► double atof(const char *nptr)
► int atoi(const char *nptr)
► char *strcpy ( char *s1, const char *s2)
► 1 and 2 only
Question No: 6 ( Marks: 1 ) - Please choose one
Dealing with structures and functions passing by reference is the most economical method
► True
► False
Question No: 7 ( Marks: 1 ) - Please choose one
Pointer is a variable which store,
► Data
► Memory Address
► Data Type
► Values
Question No: 8 ( Marks: 1 ) - Please choose one
Preprocessor program perform its function before ______ phase takes place.
► Editing
► Linking
► Compiling
► Loading
The C preprocessor modifies a source code file before handing it over to the compiler. You're most likely used to using the preprocessor to include files directly into other files,
Question No: 9 ( Marks: 1 ) - Please choose one
Which of the following can not be a variable name?
► area
► _area
► 10area
► area2
Question No: 10 ( Marks: 1 ) - Please choose one
Which looping process is best, when the number of iterations is known?
► for
► while
► do-while
► all looping processes require that the iterations be known
Question No: 11 ( Marks: 1 ) - Please choose one
Which character is inserted at the end of string to indicate the end of string?
► new line
► tab
► null
► carriage return
null character inserted at the end of the string by C automatically
Question No: 12 ( Marks: 1 ) - Please choose one
How many bytes are occupied by declaring following array of characters?
char str[] = “programming”;
► 10
► 11
► 12
► 13
11 plus one for null char (11+1= 12)
Question No: 13 ( Marks: 1 ) - Please choose one
Which of the following header file defines the rand() function?
► iostream.h
► conio.h
► stdlib.h
► stdio.h
The function is rand() and is in the standard library. To access this function, we need to include <stdlib.h> library in our program. This function will return a random number. The number can be between 0 and 32767.
Question No: 14 ( Marks: 1 ) - Please choose one
Commenting the code _____________________
► Makes a program easy to understand for others.
► Make programs heavy, i.e. more space is needed for executable.
► Makes it difficult to compile
► All of the given options.
Question No: 15 ( Marks: 1 ) - Please choose one
What's wrong with this for loop?
for (int k = 2, k <=12, k++)
► the increment should always be ++k
► the variable must always be the letter i when using a for loop
► there should be a semicolon at the end of the statement
► the commas should be semicolons
Question No: 16 ( Marks: 1 ) - Please choose one
For which array, the size of the array should be one more than the number of elements in an array?
► int
► double
► float
► char
Question No: 17 ( Marks: 1 )
To Which category of the software “Compiler and Interpreter” belongs?
They belong to system software.
There are two type of system software
1. Operating system
2. Language translators.
These are part of language translators
Question No: 18 ( Marks: 1 )
What is the result of the expression x = 2 + 3 * 4 – 4 / 2
12
first multiplies 3*4 = 12 then Division 4/2 = 2
2+12-2 = 12
Question No: 19 ( Marks: 2 )
Write a declaration statement for an array of 10 elements of type float. Include an initialization statement of the first four elements to 1.0, 2.0, 3.0 and 4.0.
float tmp [10] = {1.0,2.0,3.0,4.0};
Question No: 20 ( Marks: 3 )
Write down the output of the following code?
int array[7], sum = 0;
for(int i=0;i<7;i++)
{
array[i] = i;
sum+= array[i];
}
cout<< “ Sum = “ <<sum;
answer: 21
Loop will run times starts from zero and add values from 1 to 6 which is equal to 21
What will be the output of the following segment of C++ code?
int A[5] = {1 , 2, 3, 4};
int i;
for (i=0; i<5; i++)
{
A[i] = 2*A[i];
cout << A[i] << " ";
}
2 4 6 8 0
Loops will run 5 times as its starting from zero. It will multiply the value of each item in array as last time is not initialized so it will multiply it with zero to give zero as output
Question No: 22 ( Marks: 10 )
Write a C++ program that will determine if a departmental store customer has exceeded the credit limit on a charge account.
Program should input the following facts in five variables
1. Account number
2. Balance at the beginning of month (Beginning balance)
3. total of all items charged by customer this month (charges)
4. total of all credits (credits)
5. allowed credit limit
Calculate the new balance
New balance = Beginning balance + charges – credits
Determine if new balance exceeds the allowed credit limit. For those customers whose credit limit is exceeded. The program should display the message “Credit Limit exceeded.”
1. The statement cout << yptr will show the __________the yptr points to.
Value
Memory Address
Variabvle
None of given
Value
Memory Address
Variabvle
None of given
2. char **argv can be read as__________________.
Pointer to Pimter
Pointer to Char
Pointer to Pointer to Char (page 177)
None of given
2. _______________are conventional names of the command line parameters of the ‘main()’ function.
‘argb’ and ‘argv’
‘argc’ and ‘argv’
‘argc’ and ‘argu’
None of Given
‘argb’ and ‘argv’
‘argc’ and ‘argv’
‘argc’ and ‘argu’
None of Given
3. ___________ Returns true if c is a digit and false otherwise.
int isalpha( int c )
int isalnum( int c )
int isxdigit( int c )
int isdigit( int c )
int isalpha( int c )
int isalnum( int c )
int isxdigit( int c )
int isdigit( int c )
4. In the case of pointer to pointer or _______________, the first pointer contains the address of the second pointer, which contains the address of the variable, which contains the desired value.
double dereference (page 175)
Single dereference
dereference
None of the given
double dereference (page 175)
Single dereference
dereference
None of the given
5. _______________________ contains functions for manipulations of character data.
ctype.h
iostream.h
string.h
None of the given
ctype.h
iostream.h
string.h
None of the given
6. Dereferencing operator is represented by _______
*
+
-
None of the given
*
+
-
None of the given
7. In_________, we try to have a precise problem statement
Analysis
Design
Coding
None of the given
Analysis
Design
Coding
None of the given
1- Memory allocated from heap or free store _____________________.
Select correct option:
can be returned back to the system automatically
can be allocated to classes only
cannot be returned back unless freed explicitly using malloc and realloc
cannot be returned back unless freed explicitly using free and delete operators
2- Once the _______________ are created, they exist for the life time of the program
Select correct option:
local variables
non static variables
static variables
automatic variables
Once the static variables are created, they exist for the life of the program. They do not die. So returning their reference is all right.
3- The members of a class declared with the keyword struct are _____________by default.
Select correct option:
static
private
protected
public.
The members of a class declared with the keyword struct are public by default. A structure is inherited publicly by default.
4- If the memory in the free store is not sufficient ____________________.
Select correct option:
malloc function returns 1
malloc function returns 0
malloc functions returns NULL pointer
malloc function returns free space
if the memory in the free store is not sufficient enough to fulfill the request. malloc() function returns NULL pointer if the memory is not enough. In C++, 0 is returned instead of NULL pointer.
5. This reference to a variable can be obtained by preceding the identifier of a variable with ________________.
Select correct option:
dot operator
ampersand sign &
^ sign
· operator
6- Once an object is declared as a friend, _________________________.
Select correct option:
it has access to all non-public members as if they were public
it has access to public members only
it has no access to data members of the class
it has to protected data members only
· Friend declarations introduce extra coupling between classes
· Once an object is declared as a friend, it has access to all non-public members as if they were public
· Access is unidirectional If B is designated as friend of A, B can access A’s non-public members; A cannot access B’s
· A friend function of a class is defined outside of that class's scope
7- Reference variables must _________________.
Select correct option:
not be initialized after they are declared
be initialized after they are declared
contain integer value
contain zero value
8- If the request of new operator is not fulfilled due to insufficient memory in the heap ____________________.
Select correct option:
the new operator returns 2
the new operator returns 1
malloc functions returns NULL pointer
malloc function returns free space
9- Reference is not really an address it is ______________.
Select correct option:
a synonym
an antonym
a value
a number
10- If the request of new operator is not fulfilled due to insufficient memory in the heap ____________________.
Select correct option:
the new operator returns 2
the new operator returns 1
the operator returns 0
free operator returns nothing
11- Functions declared with the _______________ specifier in a class member list are called friend functions of that class.
Select correct option:
protected
private
Select correct option:
protected
private
Public
friend
Functions declared with the friend specifier in a class member list are called friend functions of that class. Classes declared with the friend specifier in the member list of another class are called friend classes of that class.
12- public or private keywords can be ____________
Select correct option:
written only for once in the class or structure declaration
written multiple times in the class or structure declaration
written only twice in the class declaration
written outside the class
Select correct option:
written only for once in the class or structure declaration
written multiple times in the class or structure declaration
written only twice in the class declaration
written outside the class
good practice is to write public or private keywords only once in the class or structure declaration, though there is no syntactical or logical problem in writing them multiple times.
13-The friend keyword provides access _____________.
Select correct option:
in one direction only in two directions
to all classes
to the data members of the friend class only
Select correct option:
in one direction only in two directions
to all classes
to the data members of the friend class only
The friend keyword provides access in one direction only. This means that while OtherClass is a friend of ClassOne, the reverse is not true.
14- References cannot be uninitialized. Because it is impossible to _______________
Select correct option:
Select correct option:
reinitialize a pointer
reinitialize a reference initialize a NULL pointer
cast a pointer
reinitialize a reference initialize a NULL pointer
cast a pointer
References cannot be uninitialized. Because it is impossible to reinitialize a reference,
15- new operator can be used for ______________.
Select correct option:
only integer data type
only char and integer data types
integer , float, char and double data types
dot operator
Similarly, new operator can be used for other data types like char, float and double etc.
16- The destructor is used to ______________.
Select correct option:
allocate memory
deallocate memory
create objects
allocate static memory
16- If we want to allocate memory to an array of 5 integers dynamically, the syntax will be _____________.
Select correct option:
int *iptr ; iptr = new int[5] ;
integer iptr** ; iptr= new int[5]
int iptr ; iptr= int [5]
iptr= new[5]
17- Memory allocated from heap or free store _____________________.
Select correct option:
can be returned back to the system automatically
can be allocated to classes only
cannot be returned back unless freed explicitly using malloc and realloc
cannot be returned back unless freed explicitly using free and delete operators
The memory allocated from free store or heap is a system resource and is not returned back to the system unless explicitly freed using delete or freeoperators.
18- Operator overloading is to allow the same operator to be bound to more than one implementation, depending on the types of the _________.
Select correct option:
Compilers
Operands
Function names
Applications
Operator overloading is to allow the same operator to be bound to more than one
implementation, depending on the types of the operands.
19- The operator to free the allocated memory using new operator is ________________.
Select correct option:
free
delete
remove
The operator to free the allocated memory using new operator is delete. So whenever,
we use new to allocate memory, it will be necessary to make use of ‘delete’ to deallocate
the allocated memory.
20- The concept of friend function negates the concept of _________________.
Select correct option:
inheritance
polymorphism
persistence
encapsulation
cs201 solved quizzes http://vukwl.blogspot.com/search/label/CS201%20Quizzes
ReplyDelete