A

Admin • 833.24K Points
Coach

Q. Which of the following is the correct way to initialize a string in C++?

  • (A) string str = 'Hello';
  • (B) string str = "Hello";
  • (C) string str = H e l l o;
  • (D) string str = [Hello];
  • Correct Answer - Option(B)
  • Views: 33
  • Filed under category C++
  • Hashtags:

Explanation by: Admin

In C++, strings are initialized with double quotes. 'string str = "Hello";' is the correct way.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.