60 likes | 198 Views
Hello World. #include < iostream > using namespace std; int main () { cout << "Hello World!"; return 0; }. #include < iostream > This specific file ( iostream ) includes the declarations of the basic standard input-output library in C++. using namespace std;
E N D
Hello World #include <iostream> using namespace std; int main () { cout << "Hello World!"; return 0; }
#include <iostream> • This specific file (iostream) includes the declarations of the basic standard input-output library in C++. • using namespace std; • All the elements of the standard C++ library are declared within what is called a namespace. • int main () • it is essential that all C++ programs have a main function • { • cout << "Hello World!"; • cout (and cin) represents the standard output stream in C++, • return 0; • }
// my second program in C++ #include <iostream> using namespace std; int main () { cout << "Hello World! "; cout << "I'm a C++ program"; return 0; }
// my first string #include <iostream> #include <string> using namespace std; int main () { string mystring; mystring = "This is the initial string content"; cout << mystring << endl; mystring = "This is a different string content"; cout << mystring << endl; return 0; }
endl // endl #include <iostream> usingnamespace std; int main () { int a=100; double b=3.14; cout << a; cout << endl; // manipulator inserted alone (adds newline) cout << b << endl << a*b; // manipulator in concatenated insertion return 0; }