Home » C++ Programming » Modifier Types » Question
  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    struct N
    {
    int k;
    char ch;
    float p;
    void function();
    };
    void N :: function() {}
    struct M
    {
    public:
    int k;
    char ch;
    float p;
    void function();
    };
    void M :: function() {}
    int main()
    {
    N obj1; M obj2;
    obj1.k = obj2.k = 2;
    obj1.ch = obj2.ch = 'U';
    obj1.p = obj2.p = 5.125;
    obj1.function();
    obj2.function();
    cout << "Value Allocated in memory...";
    return 0;
    }
    1. Compilation Error
    2. Runtime Error
    3. Value Allocated in memory...
    4. 2 U 5.125
    5. None of these
Correct Option: C

In this program, We used access specifiers for structures, As we declared all methods as public, The values can be allocated.



Your comments will be displayed only after manual approval.