Why C++ ?
· It is an object-oriented programming language OOP (programs are modeled around objects and classes);
· It offers a clear and well-structured code;
· It helps developers to model real-world problems;
· It is fast and flexible, well-respected for its portability and low-level functionality.
What is C++ used for ?
C++ focuses on large system performance, so it is used in a wide variety of programs and problems where performance is important.
This includes operating systems, game development, 3D animation, web browsers, software for offices, medical software, and more. C++ is used in all Blizzard games, most console games, Adobe Photoshop, Mozilla Thunderbird, PDF technologies and MRI scanners.
About C++ :
C++ is a programming language created by Bjarne Stroustrup and his team at Bell Laboratories in 1979. It was derived from the C language; Bjarne’s goal was to add object-oriented programming into language.
Main characteristics: there is no automatic memory management like in Java; you have to choose between how memory is allocated (i.e. stack or heap); there is no interpreter in C++ to stop you from writing buggy code.
Bjarne Stroustrup
Syntax
Syntax is a set of rules that define how you write and understand C++ code. Syntax sets character structures that a computer can interpret. A command written without proper syntax generates syntax error, usually causing the program to fail. For example, every command line must end with the symbol ";" .
Keywords
Keywords are predetermined names that can be used to identify things in your code. Keywords are identifiers for particular objects, variables or actions. You can also make your own keywords. Here are a few examples of keywords: for, float, public, void, int, return. Take a look at a complete list of keywords here.
#include <iostream>///header file library
using namespace std;//using standard namespace
int main() {
cout<< "Welcome to ProgMath online course!\n"; /*first object for display */
cout<< "Learn C++ in 10 steps!";//second object
return 0;//code 0 indicates that the program was successful.
}
Let us look at the various parts of the above program:
The C++ language defines several headers, which contain information that is either necessary or useful to your program. For this program, the header <iostream> is needed.
The line using namespace std; tells the compiler to use the std namespace.
The line int main() is the main function where program execution begins.
The next line cout <<" Welcome to ProgMath online course! \n"; causes the message " Welcome to ProgMath online course!” to be displayed on the screen.
Single-line comments begin with // and stop at the end of the line.
The line cout<<" Learn C++ in 10 steps!"; causes the message “Learn C++ in 10 steps!” to be displayed on the screen.
The next line return 0; terminates main( )function and causes it to return the value 0 to the calling process.