Sunday, April 21, 2019

Introduction to C++ Programming

This article will introduce C++ programming from the ground up.
from

  This article won't teach you all the basics of C++ programming, but it gives
from

  You are the foundation of learning C++ programming, remember to learn further,
from

  The base should be very powerful, which is what this article is trying to do. It will let
from

  You know that many foundations help you learn the language further.
from

  C++ was developed by Bjarne Stroustrup at Bell Labs in the 1980s.
from

  Object-oriented programming language. Many people think that this language is a language
from

  Extension of programming language C. Extension of programming language
from

  Get the way to create C++ by adding classes to C. This is the original reason for C++.
from

  Called "C with Classes." C++ programming language derived
from

  The name of the increment operator used from C, which increments the value of the variable.
from

  The symbolic name of C++ does indicate that the language is an enhanced version
from

  C.

feature
C++ programming language: -

  1. The C++ programming language is a highly flexible, versatile and very powerful programming language for developing any software, especially system operating systems, native operating systems, compilers, etc.
  2. C++ is the best language for developing reusable programs, which is important to keep production costs to a minimum.
Comparison of C++ programming languages

Let's see how C++ compares
from

  With other programming languages. Can divide all programming languages
from

  Divided into two categories: -

  1. Problem-oriented or high-level languages: These languages ​​are designed to provide better programming efficiency, ie faster program development. Examples of languages ​​that fall into this category include FORTRAN, BASIC, and others.
  2. Machine-oriented language or low-level programming language. These languages ​​are designed to provide better machine efficiency, ie faster program execution. Examples of programming languages ​​belonging to this category are assembly language and machine language.
C++ is between these two categories. This is why it is often called
from

  An intermediate language because it is designed to have both: relatively good
from

  Programming efficiency [compared to machine-oriented languages] and relative
from

  Good machine efficiency [compared to problem-oriented languages].

Getting started with C++ programming

Communicate with
from

  The computer involves speaking the language of the computer, immediately
from

  Exclude English as the language of communication with the computer. But there
from

  It is an approximate analogy between learning English and learning C++ language.
from

  The classic way to learn English is to learn letters or characters first.
from

  Use in the language, then learn to combine these letters into sentences
from

  Combine with sentences to form paragraphs. Learning C++ programming is similar
from

  And it's easier.

So we have to learn how to write programs first, not directly
from

  Know what letters, numbers and special symbols are used in C++, then how to use
from

  Construct these, constants, variables and keywords, and finally how to build
from

  All of this combines to form an instruction. Will combine a set of instructions
from

  Later, a program was formed. from

character set
Character set is a group
from

  A valid character that the language can recognize. Any character representation
from

  Letters, numbers or any other logo. C++ has the following character set:

Letter AZ, az

Number 0-9

Special symbol space + - * /' "[][] etc.

White spaces, spaces, horizontal labels, carriage returns, line feeds, etc.

Other characters, C++ can handle any of 256 ASCII characters as data or
from

  Text.

The letters, numbers, and special symbols when correctly combining formal constants,
from

  Variables and keywords. Let us see what these are: -

  • constant: A constant is a data item whose value is never changed during program execution. The C++ programming language allows several types of constants.
  • variable: Variables are the number that can change during program execution. The variable name is the name given to the location in the computer's memory where the value is stored.
  • Key words: These are words that convey a special meaning to the language compiler. A keyword is a word that has been interpreted to the C++ compiler. Keywords cannot be used as variable names, because if we do, we will try to assign new meaning to the keywords, which is not allowed by the computer. Examples of keywords include if, void, for, switch, and so on.
Data type in C++

Data type is a means of identifying types
from

  Data and related operations to handle it. In C++, the data types are very broad
from

  Two types: -

  1. Basic data type: These are predefined by the C++ language itself. There are at least five basic data types.
    • Char- indicates that this type of declarative variable can store characters
    • Int-present integer
    • Float- represents a floating point number
    • Void-representationations worthless data
  2. Derived data type: These are built from basic types. I won't give you more details because it's a bit advanced.
Description in the C++ programming language

Now we see
from

  The next logical step is a different type of constant, variable and keyword
from

  Learn how they combine to form instructions.

  • Type declaration description: Declare the type of variable used in the program. E.g: - from

    Int num;
    Here the variable num is declared as an int[eger] type.
  • Input/output instructions: Performs the function of providing input data to the program and obtaining output results from it. E.g: - from

    Cin >> a;
    In the first line, cout takes the input from the keyboard and assigns it to the pre-declared variable a. In the second line ' Hello ' use the function cout to print.
  • Arithmetic instructions: Perform arithmetic operations between constants and variables. E.g: - from

    c = a + b;
    Here c is assigned a value which is the sum of the variables a and b.
  • Control instructions: Controls the order in which various statements are executed in a C++ program. E.g: - from

    If[a> b]func1[];
    This checks if a is greater than b, and if so, the program execution goes to the user-defined function ' func1'.
First C++ program

Armed knowledge
from

  Variables, constants, keywords, etc. We will write our first C++
from

  program.

Each instruction in a C++ program combines a series of statements. These ones
from

  Statements must appear in the order we want them to execute.

The following rules apply to all C++ programs, whether long or complex
from

  they are

  • You can insert a space between two words to increase the readability of the statement. However, spaces are not allowed in variables, constants, or keywords.
  • Usually all statements are entered in lowercase letters.
  • C++ has no specific rules for the location of the write statement. This is why it is often referred to as a free-form language.
  • Any C++ statement always ends with a semicolon [;].
Now let's look at a program that calculates the sum of two numbers.
from

  By the user.

/ / Calculate the sum of two given numbers

#include

Main[]

{

Int num1; //Declare the variable num1 of type int[etger]

Int num2; //Declare the variable num2 of type int[etger]

Int sum; / / declare the variable of type int [etger] and

Cin >> num1; // accept input and store to var num1

Cin >> num2; // accept input and store it in var num2

Sum = num1 + num2; //add vars num1&num2

COUT


Some useful tips: -
  • Any C++ program is just a combination of functions. main[] is such a function that always exists in one or another form of C++ program. Mainly after the need for empty brackets.
  • The set of statements associated with a function is contained in a pair of parentheses Ex. Main[]{statement1; statement 2; statement 3; statement4;
  • Declare any variables before using them.
  • Any C++ statement should end with a semicolon.
  • Iostream.h is the file needed to use the cin and cout functions, it is included in the program, with the include keyword.
Summary

After reading the article, you get it.
from

  In the introduction to C++ programming, you now know what C++ is and how to use it.
from

  You now know the C++ language and have taught some of the most basic parts.
from

  C++. You have learned how to declare variables and how to use them in arithmetic
from

  operating. In one sentence, you already know C++ programming.
from

  Will help you learn the language further.




Orignal From: Introduction to C++ Programming

No comments:

Post a Comment