Page 1 of 1

What happens if the following code is compiled on both C and C++?

Posted: Wed Jul 13, 2022 7:51 pm
by answerhappygod
#include<stdio.h>
struct STRUCT
{
private:
int a;
};
int main()
{
printf("%d\n", (int)sizeof(struct STRUCT));
return 0;
}
a) The program runs fine and both prints output “HELLO THIS IS STRUCTURE”
b) The program gives an error in case of C but runs perfectly in case of C++
c) The program gives an error in case of C++ but runs perfectly in case of C
d) The program gives an error in case of both C and C++