Explained Code
iostream : C++ input/output streams are primarily defined by iostream, a header file that is part of the C++ standard library (the same stands for input/output stream)
stdlib.h : stdlib.h is the header of the general purpose standard library of C programming language which includes functions involving memory allocation, process control, conversions and others. It is compatible with C++ and is known as cstdlib in C++. The name "stdlib" stands for "standard library".
using namespace std: The built in C++ library routines are kept in the standard namespace. That includes stuff like cout, cin, string, vector, map, etc. Because these tools are used so commonly, it's popular to add "using namespace std" at the top of your source code so that you won't have to type the std:: prefix constantly.
int main() : This is the main function.
system("cls"): We use this code to clear the screen. So your output will be printed out freshly. This is a part of the stdlib.h header file. If you need to use this code you need to include stdlib.h header file at the start.
cout : This will print out the output. It is part of the iostream library.
\t : This stands for a tab
\n : This stands for a new line
system("pause") : This will generate an output as "Press any key to continue..." and wait until user presses any key to exit from the program.
Output:
iostream : C++ input/output streams are primarily defined by iostream, a header file that is part of the C++ standard library (the same stands for input/output stream)
stdlib.h : stdlib.h is the header of the general purpose standard library of C programming language which includes functions involving memory allocation, process control, conversions and others. It is compatible with C++ and is known as cstdlib in C++. The name "stdlib" stands for "standard library".
using namespace std: The built in C++ library routines are kept in the standard namespace. That includes stuff like cout, cin, string, vector, map, etc. Because these tools are used so commonly, it's popular to add "using namespace std" at the top of your source code so that you won't have to type the std:: prefix constantly.
int main() : This is the main function.
system("cls"): We use this code to clear the screen. So your output will be printed out freshly. This is a part of the stdlib.h header file. If you need to use this code you need to include stdlib.h header file at the start.
cout : This will print out the output. It is part of the iostream library.
\t : This stands for a tab
\n : This stands for a new line
system("pause") : This will generate an output as "Press any key to continue..." and wait until user presses any key to exit from the program.
// my first program in c++ #include <iostream> #include <stdlib.h> using namespace std; int main(){ system("cls"); //clears the previous screen cout << "\t\t\t============\n\t\t\thello World!\n\t\t\t============\n\n"; //Printing the output system("pause"); //wait for input }
Output:
No comments:
Post a Comment