Enumerations C++ MCQ

Errorlogger
0
1. Identify the correct option.
a) enumerators are contants
b) enumerators are user defined types
c) enumerators are unchangables.
d) character

Answer:b


2. In which type does the enumerators are stored by the compiler?
a) string
b) integer
c) float
d) none of the mentioned

Answer:b


3. To which of these enumerators can be assigned?
a) integer
b) negative
c) enumerator
d) all of the mentioned

Answer:d


4. What will happen when defining the enumerated type?
a) it will not allocate memory
b) it will allocate memory
c) it will not allocate memory to its variables
d) none of the mentioned

Answer:a


5. Which variable does equals in size with enum variable?
a) int variable
b) float variable
c) string variable
d) none of the mentioned

Answer:a


6. What is the output of this program?
  1.     #include <iostream>
  2.     using namespace std;
  3.     enum  cat {
  4.         temp = 7
  5.     };
  6.     int main()
  7.     {
  8.         int age = 14;
  9.         age /= temp;
  10.         cout << "If you were cat, you would be " << age << endl;
  11.         return 0;
  12.     }
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) none of the mentioned

Answer:b


7. What is the output of this program?
  1.     #include <iostream>
  2.     using namespace std;
  3.     enum test {
  4.         A = 32, B, C
  5.     };
  6.     int main()
  7.     {
  8.         cout << A << B<< C;
  9.         return 0;
  10.     }
a) 323334
b) 323232
c) 323130
d) none of the mentioned

Answer:a


8. What is the output of this program?
  1.     #include <iostream>
  2.     using namespace std;
  3.     enum colour {
  4.         green, red, blue, white, yellow, pink
  5.     };
  6.     int main()
  7.     {
  8.         cout << green<< red<< blue<< white<< yellow<< pink;
  9.         return 0;
  10.     }
a) 0123456
b) 1111111
c) compile time error
d) runtime error

Answer:a


9. What is the output of this program?
  1.     #include <iostream>
  2.     using namespace std;
  3.     int main()
  4.     {
  5.         enum channel {star, sony, zee};
  6.         enum symbol {hash, star};
  7.         int i = 0;
  8.         for (i = star; i <= zee; i++) {
  9.             printf("%d ", i);
  10.         }
  11.         return 0;
  12.     }
a) 012
b) 123
c) compile time error
d) runtime error

Answer:c


10. What is output of the this program?
  1.     #include <iostream>
  2.     using namespace std;
  3.     int main()
  4.     {
  5.         int i;
  6.         enum month {
  7.             JAN = 1, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
  8.         };
  9.         for (i = MAR; i <= NOV; i++)
  10.             cout << i;
  11.         return 0;
  12.     }
a) 01234567891011
b) 123456789101112
c) 34567891011
d) 123456789

Answer:c
Tags

Post a Comment

0Comments

Post a Comment (0)

#buttons=(Accept !) #days=(30)

Our website uses cookies to enhance your experience. Check Now
Accept !