What will be the output of the following C++ code?

#include <iostream>
   using namespace std;
   int main()
   {
       float num1 = 1.1;
       double num2 = 1.1;
       if (num1 == num2)
          cout << "stanford";
       else
          cout << "harvard";
       return 0;
   }

a) harvard
b) stanford
c) compile time error
d) runtime error

1 thought on “What will be the output of the following C++ code?”

  1. a
    Explanation: 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.
    Output:
    $ g++ float3.cpp
    $ a.out
    harvard

Leave a Comment