July 9, 2021 in C and CPP
A relational operator
1.6 A relational operator
A) assigns one operand to another
B) yields a Boolean result
C) logically combines two operands
D) None of the above
July 9, 2021 in C and CPP
1.6 A relational operator
A) assigns one operand to another
B) yields a Boolean result
C) logically combines two operands
D) None of the above
July 9, 2021 in C and CPP
1.5 The friend functions are used in situations where
A) we want to have access to unrelated classes
B) dynamic binding is required
C) we want to exchange data between classes
D) none of the above
July 9, 2021 in C and CPP
1.4 When the break statement is encountered inside a loop, which one of the following
occurs?
A) control goes to the end of the program
B) control leaves the function that contains the loop
C) causes an exit from the innermost loop containing it
D) causes an exit from all the nested loop
July 9, 2021 in C and CPP
1.3 What would be the output of the following program?
int main( )
{
int x, y=10,z=10;
x=(y==z);
cout<<x;
return 0; }
A) 0
B) 1
C) 10
D) error
July 9, 2021 in C and CPP
1.2 Which of the following will produce a value of 9 if x=8.7?
A) floor(x)
B) abs(x)
C) log(x)
D) ceil(x)
July 9, 2021 in C and CPP
1.1 Consider the following statements:
int x = 22, y = 15;
x = (x<y) ? (x+y) : (x-y);
What will be the value of x after executing these statements?
A) 22
B) 37
C) 7
D) Error. Cannot be executed.
July 9, 2021 in C and CPP
b) What is a class template? Write a template-based complete program for adding two
objects of the vector class. Use dynamic data members instead of arrays for storing
vector elements.
July 9, 2021 in C and CPP
a) Write a program to demonstrate the catching of all exceptions. What happens when a
raised exception is not caught by catch-block (in the absence of catching all exceptions
block)?
July 9, 2021 in C and CPP
8. Write a program disp to display the contents of a random file beginning with the location you specify on the command line.
disp file.txt 15
July 9, 2021 in C and CPP
c) Can we place two or more catch blocks together to catch and handle multiple types of
exceptions thrown by a try block? If your answer is yes, please write the syntax.