Vidyalelo
C++ Programming · Q54

Introduction to C++

Programming · C++ Programming · question 54

Q54

What happens if we run the following code in both C and C++? #include struct STRUCT int a = 5; int func() printf("%d ", a); ; int main() struct STRUCT s; s.func(); 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++
Answer
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++

Answer: Option B

Solution

Answer: Option B
No explanation is given for this question Let's Discuss on Board