πŸ“Š C++
Q. What happens if we execute the following code in C and C++?
Code:
#include<stdio.h>
struct STRUCT
{
  int x;
  int f()
  {
      printf("Welcom to StackHowTo\n");
  }
};
int main()
{
  struct STRUCT s;
  s.f();
  return 0;
}
  • (A) The program returns an error in C and C++
  • (B) The program returns an error in C++ but works perfectly in C.
  • (C) The program works correctly in C and C++ and displays “Welcom to StackHowTo” as output.
  • (D) The program returns an error in C but works perfectly in C++.
πŸ’¬ Discuss
βœ… Correct Answer: (D) The program returns an error in C but works perfectly in C++.

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
217
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Ram Sharma
Publisher
πŸ“ˆ
89%
Success Rate