Multiple choice

What is the output of C++ program given below?

#include<iostream> using namespace std; int main() { typedef int hello; hello i=9.9; cout<<i; }

  1. 9

  2. 9.9

  3. 9.0

  4. Error in the program

  5. None of the above

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

 typedef creates a new name for a given datatype.

typedef int hello;     //hello is the new name of integer datatype.

hello i=9.9; cout<<i;

Which displays value of 'i'. As 'i' is of integer datatype because is declared as hello type which is the name given to integer datatype using typedef. Hence, prints 9.