1. Open your dev C++ IDE.
2. Start a new project.
Now type this codes on the environment.....
#include <iostream>
using namespace std;
int main()
{
cout << " Hello world";
cin.get();
return 0;
}
Now i will explain this code line by line.
#include <iostream> : C++ contain a wide range of header files which contains information that is either necessary or useful to your program.
Yeah, "necessary" i deliberately use the word necessary because when you are writing some program there are header files that must be included else some keywords will turn out to be a bug.
For this program our header file is <iostream> we dont need more than that since it contain all what we need to write this program.
using namespace std: This tells the compiler to use the std namespace.
int main(): The is a function, every program must have a function. In C++, program execution start from the main function. In a nut shell this is where the program execution starts.
cout << " Hello world" : This cause the the message " Hello world" to be displayed on the screen. The keyword cout is called standard output.
Note my deliberate mistake, the spaces between << " Hello world" . In C++ that is called a white space which has no effect on the program when executed.
cin.get : The will allow the message "Hello world" to be displayed on the screen.If cin,get(); is removed from the program you will see that the message will only come as flash.
return 0 : This terminate the main() function and causes it to return a value of 0 to the calling process.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment