Home / MCQ Bank / Computer
Computer Introduction To C Plus Plus

What happens if the following code is compiled on both C and C++? #include<stdio.h> struct STRUCT { private: int a; }; int main() { printf("%d\n", (int)sizeof(struct STRUCT)); return 0; }

Select the best option to verify your answer:
Show Correct Answer
Correct Answer: Option B • The program gives an error in case of C but runs perfectly in case of C++

Related Computer Questions

How many Margins are there on a page? What will be the output of the following C++ code? #include<iostream> using namespace std; class Base { public: Base() { cout<<"Constructing Base \n"; } ~Base() { cout<<"Destructing Base \n"; } }; class Derived: public Base { public: Derived() { cout<<"Constructing Derived \n"; } ~Derived() { cout<<"Destructing Derived \n"; } }; int main(void) { Derived *d = new Derived(); Base *b = d; delete b; return 0; } Window key + U What are mandatory parts in the function declaration? Which problem is best solved using Dynamic Programming by maintaining a 2D table to store results?