how to print in cpp

#include <iostream>

int main() {
    std::cout << "Hello, world!" << std::endl;
    return 0;
}
  1. #include <iostream>: This line includes the input/output stream library in the program.

  2. int main() { ... }: This is the main function where the program execution starts.

  3. std::cout << "Hello, world!" << std::endl;: This line uses the "cout" object from the "std" namespace to output the text "Hello, world!" followed by a newline character.

  4. return 0;: This line indicates that the program has executed successfully and is returning a value of 0.