Question 8
The three values that can be used to initialize a pointer are_____________,__________ and___________.
d. 0, NULL, an address |
Question 10
What is the output of the program?
#include<iostream>
usingnamespace std;
int main() {
char str[] = "de_dust";
for (int i=strlen(str)-1; i>=0; i--)
cout << str[i];
cout << endl;
return 0;
}
d. tsud_ed |
Question 11
A C++ program that prints three lines of output must contain three statements using cout and the stream insertion operator.
Ответ:
True False
Question 13
Find the error in the following program segment:
void product(void){
int a = 0, b = 0, c = 0;
int result = 0;
cout << "Enter three integers: ";
cin >> a >> b >> c;
result = a * b * c;
cout << "Result is " << result;
return result;
}
c. void product(void){ int a = 0, b = 0, c = 0; int result = 0; cout << "Enter three integers: "; cin >> a >> b >> c; result = a * b * c; cout << "Result is " << result; } |
Question 17
Write a C++ statement or a set of C++ statements to calculate the value of 2.5 raised to the power 3 using function pow. Print the result with a precision of 2 in a field width of 10 positions
a. cout << fixed << setprecision(2) << setw(10) << pow(2.5, 3) << endl; |
Question 18
Which of the following lines should NOT compile?
1 int main()
2 {
3 int a = 2;
4
5 int* b = &a;
6
7 int const* c = b;
8
9 b = c;
10
11 return 0;
12 }
Question 19
What header file contains C++ file I/O instructions?