Home » C++ Programming » Modifier Types » Question
  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    class Abhay
    {
    public:
    int age;
    };
    int main()
    {
    Abhay obj;
    obj.age = 24;

    cout << "Abhay is " ;
    cout << obj.age << " years old.";
    }
    1. years old.
    2. 24
    3. Abhay is
    4. Abhay is 24 years old.
    5. None of these
Correct Option: D

In this program, We passed the value from main function to class and returning it to the main and then printing it.



Your comments will be displayed only after manual approval.