The definition of I in C language programming can only be int. Can it be double precision or floating?
Of course. I don't know what your real problem is, I can only guess and give a stupid answer based on this guess. Usually, the definition of a variable consists of a data type and a variable name. Data type is the modification of variables and adjectives. The choice of this modifier is not arbitrary. Maybe you've seen too much. Int i exists in all programs. This statement. It's just a coincidence. This situation is like the phrase "red flower" in many articles. "Red flower" is not a rule. Flowers can be blue or white ... it helps to understand the concept of variables. Here's an analogy. Creating variables in C programs is just like creating containers. Variables are containers that can hold things. The data type of the variable is the type of container, such as suitcase and water tank. Here, containers are classified according to different contents. The name of the variable is the name of the container and the label of the container. For example, if there are multiple water tanks, if there is a sentence in the program that operates a variable and says "put a liter of water in the water tank", then the meaning is unclear. Neither the computer nor the reader of this program knows what it means, because it does not indicate which water tank it is. You can name one of these tanks a and say "put a liter of water". Programming can be said to be container oriented. Generally speaking, programs deal with abstract things, not concrete things. So that the program can be reused. For example, calculating the sum of two numbers is more meaningful than calculating the program of "7+6". So you have to ask: I can only be defined as int? Can it be double precision or floating? It's like asking: Can I only be a water cup? It can be a basin or a water tank. I'm just a label. You can use the letter I to refer to any container. In addition, let's talk about how to give a good name to a variable name. If I is quoted in many places in a program, then the name I is not well named, because I don't know what I am, a variable, a function or other C language elements. If it is a variable, we only know that there is such a container, which is a clothes box, but we don't know exactly what clothes to put. In the price calculation program, the name price is better than numbers and integers. This explanation about how to give a good name to a variable seems redundant. Because we use another language, in everyday language, you may say "the price of this dress" instead of "the number of clothes". What's the number here? Price or size, or other things ... In fact, there is not much difference between C program and natural language. C has many data types, such as char, int, float, double and so on. Their meanings: char stands for single character, int stands for basic integer, float stands for single precision decimal, and double stands for double precision decimal. When defining or declaring a variable in a C program, you must specify the data type of the variable, because C is a static compilation language and strongly typed. The computer should determine the form of variables in memory according to the information of these data types. For example, char occupies 1 byte of memory, and int occupies 2 bytes of memory. Which one is suitable depends on your needs in specific circumstances. For example, if you want to write a program to calculate the amount, you should use float, because in this demand, money is not an integer, and the maximum is one million (the maximum is seven digits). For example, if you want to write a menu selection program, the option variable should be characters, so you should choose char.