Sub-Number of Han · C Language -- let C help you with computation, C language Calculator
Before that, we learned our first C program-hello World. Now let's start to learn more and think about how to make C help you with computation.
Let's first look at the code (I haven't created a new one, or use the previous hello world. cpp ):
Okay, because I have learned the basic C framework before hello World, so I will not repeat the content I mentioned before.
Then let's take a look at the notes:
1. row 4: int is the key word of C. It can be used to define variables. In addition to int, it can also be used to define variables such as char and float. This will be detailed when we talk about the data type.
2. the fifth line: scanf is a format input statement, which is the opposite of printf and has the same usage. "% d, % d" "is used to represent the input format, where ', 'indicates the separation method, and & a and & B indicates to whom the input value is assigned. These can be customized.
3. Row 6: This is too simple. Although this article is intended to make pupils understand it, I don't think I need to explain it.
4. Row 7: the syntax of this line is not described much as we mentioned above.
Finally, let's talk about the computing that can be run in C language?
In addition to addition, subtraction, multiplication, and Division (+-*/), there are also values (=), remainder (%), power (^), and negative (-) the difference between it and minus sign is that it only targets one number, as well as auto-Plus (++) and auto-minus (--).
For example, I ++ is equivalent to I = I + 1, and I -- is equivalent to I = I-1.