Programming in C++ involves following a basic structure throughout. To understand that basic structure, the first program we learned writing in C++ will be referred to.
Data types define the type of data a variable can hold; for example, an integer variable can hold integer data, a character can hold character data, etc.
Data types in C++ are categorized into three groups:
These data types are pre-defined for a language and could be used directly by the programmer.
Examples are: Int, Float, Char, Double, Boolean
These data types are defined by the user itself.
Examples are: Class, Struct, Union, Enum
These data types are derived from the primitive built-in data types.
Examples are: Array, Pointer, Function
Some of the popular built-in data types and their applications are:
Constants are unchangeable; when a constant variable is initialized in a program, its value cannot be changed afterwards.
OUTPUT:
Special symbols that are used to perform actions or operations are known as operators. They could be both unary or binary.
For example, the symbol + is used to perform addition in C++ when put in between two numbers, so it is a binary operator. There are different types of operators. They are as follows:
Functions are the main part of top-down structured programming. We break the code into small pieces and make functions of that code. Functions could be called multiple or several times to provide reusability and modularity to the C++ program.
Functions are also called procedures or subroutines or methods and they are often defined to perform a specific task. And that makes functions a group of code put together and given a name that can be called anytime without writing the whole code again and again in a program.
Library functions are pre-defined functions in C++ Language. These are the functions that are included in C++ header files prior to any other part of the code in order to be used.
E.g. sqrt(), abs(), etc.
User-defined functions are functions created by the programmer for the reduction of the complexity of a program. Rather, these are functions that the user creates as per the requirements of a program.
E.g. Any function created by the programmer.