Data Types
- Which of three sizes of floating point types should be used when extended precision is required?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Float for single precision, double for double precision and long double for extended precision.
- What is the output of this program?
#include
using namespace std;
int main()
{
float n1 = 10.1;
double n2 = 10.1;
if (n1 == n2)
cout << "Interview";
else
cout << "Mania";
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
Float store floating point numbers with 8 place accuracy and requires 4 bytes of Memory. Double has 16 place accuracy having the size of 8 bytes.
- What is the output of this program?
#include
#include
using namespace std;
int main()
{
cout << setprecision(17);
double n = 0.2;
cout << n << endl;
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
The double had to truncate the approximation to its limited memory, which resulted in a number that is not exactly 0.2.
- What is the output of the following program?
#include
using namespace std;
int main()
{
float n = 143.0f;
cout << n << endl;
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
The value 143 is printed because of its precision.
- Which is used to indicate single precision value?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
F or f