Introduction

C++ is the extension of the C programming language. It provides object-oriented features, such as classes and templates, and it has powerful libraries for tasks such as string manipulation, sorting data, and image processing. The article C++ program 101 introduces to programming field and lets the programmer build his first program in C++.

What is C++?

C++ is a general-purpose programming language. C++ is a compiled language, meaning that it is translated into an executable form before it can be run.

It was developed by Bjarne Stroustrup starting in 1979 at Bell Labs. As a general-purpose language, C++ has been applied to various uses, from video games to operating systems and device drivers.

Why learn C++?

C++ is a general-purpose programming language that has been around for decades. It is used in everything from video games to operating systems. Learning C++ can greatly benefit anyone who wants to learn how to code and become an engineer.

This article will examine the basics of C++, what you can use it for, and why learning it will drive you a better programmer overall.

There are many reasons why people choose to learn C++. One of them is that it’s one of the most popular languages out there, so if you like to become an engineer or programmer in any field, learning C++ will help you get there faster than any other language.

Another reason is that it’s not as complicated as other programming languages like Java or Python but not as easy as JavaScript.You can do many things with C++, and you can use it for many purposes.

This language is also great for developing games because it is fast and powerful. Using C++, you can create websites or web applications that are fast and relatively simple to make. You could also use C++ to develop software that could easily be used on a touchscreen device.

C++ program 101

C++ keywords

They are predefined words specific to the C++ programming language and have meanings for the compiler.

C++ keywords from a to cC++ keywords from c to lC++ keywords from m to sC++ keywords from s to z

  • The C++ language has around 90 keywords
  • The Java language has around 50 keywords
  • The C language has around 32 keywords
  • The Python language has around 33 keywords

Be aware that the more the programming language has, the more complex the programming language is. The programmer doesn’t need to use all the keywords.

C++ identifiers

main, std, cout, cin, and endl are not C++ keywords; they are identifiers

C++ main function

The main function of a C++ program is the first function that is called when the program starts. The main function of a C++ program can have one or more parameters, and it must return an integer value.

C++ cin identifier

The c++ cin identifier is a standard input stream that reads from the keyboard and allows the user to enter an input.

The c++ cout identifier 

The c++ cout identifier is an output stream. It is a standard I/O object that can be used to display text messages on the screen.

The c++ std identifier 

The C++ Standard Library is a library of functions that are used in C++ programs. These functions can be used to manipulate strings, search for data, and perform calculations. The library contains the following identifiers:

The c++ std identifier

     – std::string  – std::cout

– std::cin      – std::strerror

The c++ endl identifier

The c++ endl identifier is used to insert a newline character into a string. It is an end-of-line character that inserts a new line in the text.

C++ ponctuation

The C++ language is standardized by the International Organization for Standardization (ISO). The Standardization ensures that C++ code can be compiled on any machine with a C++ compiler, regardless of the underlying hardware or operating system.We can use punctuation marks in C++ to make our code more readable and understandable. Here are some examples:

  • The semicolon (;) terminates a statement
  • The comma (,) separates two statements on the same line
  • The curly brace ({}) encloses a group of statements known as a block
  • Statements are things that do something. They end with a semicolon (;)

C++ #include preprocessor directive

The directives usually start with #.The C++ include directive is a preprocessor directive that instructs the compiler to insert the contents of another file into the current compilation.A C++ include directive is syntactically similar to a #include in C++ and other languages, but it’s not identical. In particular, the #include directive includes all of the content of a given file, while an #include may only include one or more specific functions or types from that file.The C++ preprocessor does not understand the C++ language. The preprocessor follows the preprocessor directives and prepares the source code for the compiler.

Comments

There are two kinds of comments: line comments and multiline comments.// This is a single-line comment/*—————————————————————- This is a multiline comment.*/The compiler never sees the comment. The comments usually explain certain things to the programmer, So it is essential to make the comments in sync and Well written and express an understanding of the code now and in the future.

The main function

Every C++ program needs to have the main function.

Model 1

Model 1

int main(){// The c++ codereturn0;}

Model 2

Model 2

int main(argument1, argument2){// The c++ codereturn0;}

int main(argument1, argument2){// The c++ codereturn0;}

The first C++ program

The first C++ program

#include <iostream>using std::cout;using std::cin;using std::endl;int main(){int choose_number;cout<<“Enter a number between 0 and 60: “<<endl;cin>>choose_number;cout<<“Good! that’s the number you entred!”<<endl;cout<<choose_number;return 0;}

The first C++ program C++ program

input and output(IO) used in the program

cout 

cout is a standard output stream that displays a message in the console.

cin

cin is a standard input stream that asks the user to tape something on the keyboard.

symbols

<< symbol

The symbol << is an insertion operator and an output stream.

>> symbol

The symbol << is an extraction operator and an input stream.

conclusion of the article

Conclusion

C++ is an excellent programming language because it has features not found in other programming languages. It also provides more flexibility than other languages, making it easier for programmers to use. The article explains all the steps to building the first c++ program after being aware of the keywords and the identifiers needed to construct every c++ program.

Pin It on Pinterest

Share This