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

#include <iostream>
   using namespace std;
   enum  cat 
   {
       temp = 7
   };
   int main()
   {
       int age = 14;
       age /= temp;
       cout << "If you were cat, you would be " << age << endl;
       return 0;
   }

a) If you were cat, you would be 5
b) If you were cat, you would be 2
c) If you were cat, you would be 7
d) If you were cat, you would be 9

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

  1. b
    Explanation: The age will be divided by using compound assignment operator and so it will return the age of the cat according to your age.
    $ g++ enum1.cpp
    $ a.out
    If you were cat, you would be 2

Leave a Comment