To start using C++, you need two things:
There are many text editors and compilers to choose from. In this tutorial, we will use an IDE (see below).
myfirstprogram.cpp
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!";
return 0;
}
Don't worry if you don't understand the code above - we will discuss it in detail in later chapters. For now, focus on how to run the code.
In Codeblocks, it should look like this:
Then, go to Build > Build and Run to run (execute) the program. The result will look something to this:
Hello World!
Process returned 0 (0x0) execution time : 0.011 s
Press any key to continue.
Congratulations! You have now written and executed your first C++ program.
When learning C++ at W3Schools.com, you can use our "Try it Yourself" tool, which shows both the code and the result. This will make it easier for you to understand every part as we move forward:
myfirstprogram.cpp
Code:
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!";
return 0;
}
Result:
Hello World!
15 videos|20 docs|13 tests
|
1. What is the importance of introduction and getting started in class 7? |
2. How can introduction and getting started help students in class 7? |
3. What should students expect during the introduction and getting started phase in class 7? |
4. How can students make the most out of the introduction and getting started phase in class 7? |
5. Are there any specific tips or strategies for students to succeed during the introduction and getting started phase in class 7? |
|
Explore Courses for Class 10 exam
|