ExamVeda
Login
Home
11
One way in which a structure differs from an array is that _____
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
12
A default constructor _____
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
13
The number 125.35 is a _____
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
14
When a class serves as a base class to others, _____
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
15
Storing a class definition in a separate file is an example of
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
16
Which is true?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
17
A class named student must have a constructor whose name is
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
18
The statement double val[15]={44.123456};
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
19
Which of the following C++ expressions will find the square root of the number 16?
Discuss
Answer & Solution
Answer: Option D
Solution:
sqrt is a function from the C++ standard library that calculates the square root of a given number. In this case, the expression sqrt(16) calculates the square root of 16.

The function pow from the C++ standard library calculates the power of a number, i.e., it raises a number to a specified power. The expression pow(16, 2) calculates 16 raised to the power of 2, which is 256, and is not the square root of 16.

sqroot is not a standard C++ function and will result in a compile-time error.

sqrt (16, 2) is not a correct syntax for the sqrt function in C++, which takes only one argument, the number for which the square root is to be calculated.

So, the correct expression to find the square root of 16 in C++ is sqrt(16).

C++ program to find out square root of 16
#include <iostream>
#include <cmath>
using namespace std;
int main() {
  cout << "Square root of 16 = ";   
  // print the square root of 16
  cout << sqrt(16);
 return 0;
}

Here is an explanation of the code:

1. #include <iostream> - This line includes the input/output stream library, which provides the cout function that is used later in the code to print the output.
2. #include <cmath> - This line includes the C++ mathematics library, which provides mathematical functions such as sqrt() that is used later in the code to calculate the square root.
3. using namespace std; - This line is used to make all the elements of the standard C++ library available to the program.
4. int main() - This is the main function of the program. All C++ programs must have a main function, which is where the program starts executing.
4. cout << "Square root of 16 = "; - This line outputs the string "Square root of 16 =" to the console.
6. cout << sqrt(16); - This line calculates the square root of 16 using the sqrt() function from the C++ mathematics library and outputs the result to the console.
7. return 0; - This line is the return statement of the main function. It returns 0, indicating that the program has executed successfully.

In summary, this program calculates the square root of 16 and outputs the result to the console.

20
It is illegal to make objects of one class members of another class
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board