Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
float f1 = 0.5;
6.
double f2 = 0.5;
7.
if (f1 == 0.5f)
8.
cout
Options:
A .  equal
B .  not equal
C .  compile time error
D .  runtime error
Answer: Option A

0.5f results in 0.5 to be stored in floating point representations.
Output:
$ g++ float.cpp
$ a.out
equal



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers