GETTING STARTED WITH C++
C++
1. What is C++?
C++ was developed by Bjarne Stroustrup at Bell labs in 1979, as an extension to the C language. C++ is a cross-platformed language that can be used to create high-performance applications. The language was updated 3 major times in 2011, 2014, and 2017 to C++11, C++14, and C++17 respectively.
2. Why Use C++?
C++ is one of the world's most popular programming languages. C++ is an object oriented language which gives a clear structure to programs and allows code to be reused. C++ is portable and can be used to develop applications that can be adapted to multiple platforms. C++ can be found in today's operating systems, Graphical User Interfaces, and embedded systems. C++ is fun and easy to learn!
To start using C++, you need two things:
- A text editor, like Notepad, to write C++ code
- A compiler, like GCC, to translate the C++ code into a language that the computer will understand
3. Install code blocks IDE.
Popular IDE's include Code::Blocks, Eclipse, and Visual Studio. These are all free, and they can be used to both edit and debug C++ code.
We will use Code::Blocks.
You can find the latest version of Codeblocks at (click here)
codeblocks downloads Download the
mingw-setup.exe
file, which will install the text editor with a compiler.4. Quickstart.
Let's create our first C++ file.
Open Codeblocks and go to File > New > Empty File.
Write the following C++ code and save the file as HelloWorld.cpp (File > Save File as):
HelloWorld.cpp
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!";
return 0;
}
Now how to run the code In Codeblocks?
You have now written and executed your first C++ program.
Example explained
1.
#include <iostream>
is a header file library that lets us work with input and output objects, such as cout
(used in line 5). Header files add functionality to C++ programs.
2.
using namespace std
means that we can use names for objects and variables from the standard library.
3.
int main()
. This is called a function. Any code inside its curly brackets {}
will be executed.
4.
cout
is an object used to output/print text. In our example it will output "Hello World".
Note: Every C++ statement ends with a semicolon
;
.
Note: The body of
int main()
could also been written as:int main () { cout << "Hello World! "; return 0; }
5.
return 0
ends the main function.1. first programming language
2. how to start programming
THANKYOU!
Comments
Post a Comment