Sample Analysis of variables, constants, arrays and strings in C++
This article will explain in detail the sample analysis of variables, constants, arrays and strings in C++. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
I. Overview of memory and addressing
The programmable device contains a microprocessor and a certain amount of temporary storage space. Temporary memory is called random access memory (RAM).
RAM is similar to the storage area of a row of lockers in a dormitory. Each locker has a number, or address. To access a specific memory unit, you need to use instructions to require the processor to get or write values from here.
The microprocessor is responsible for executing the application and obtaining the application to be executed and the associated data from the RAM, including the data displayed on the screen and the data entered by the user.
Second, variables
Explicitly specifying the address of the memory unit used for storage, such as 578, is error-prone, resulting in variables.
1. Declare variable
Variable_type variable_name
Variable_type variable_name= initial_value
The variable type indicates to the compiler the nature of the data that the variable can store, and the variable name replaces the address where the variable value is stored in memory.
Multiple variables of the same type can be declared and initialized.
Such as: int FirstNumber=0,SecondNumber=0,Multiplication=0
You can declare variables at the beginning, or you can declare variables when needed.
# include using namespace std;int main () {cout