hi cpp 1

hi cpp

#include 

using namespace std;

int main(){
 cout <<"Hi" << "\n";
  //"Hello world" and a newline is output.
 return 0;
}

Here is what the above code is Doing:
1. The first line of code is a preprocessor directive. This tells the compiler to include the contents of the iostream header file in the program. This header file contains the definitions of the cout object and the endl manipulator.
2. The next line of code is a using namespace std; statement. This statement tells the compiler to use the std namespace. Namespaces are a relatively recent addition to C++. They provide a method of grouping entities like classes, objects and functions under a name. In this case, the entities defined in the standard C++ library are declared within the std namespace.
3. The next line of code is the main() function. This is where the program starts when executed.
4. The next line of code is a cout statement. This statement outputs the string "Hi" followed by a newline character to the screen.
5. The next line of code is a return statement. This statement terminates main() and causes it to return the value 0 to the calling process.
6. The last line of code is a closing brace. This brace ends the main() function.

Similar Posts