Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the basic arithmetic operators in C language

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "what are the basic arithmetic operators in C language". In daily operation, I believe that many people have doubts about the basic arithmetic operators in C language. I have consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "what are the basic arithmetic operators in C language?" Next, please follow the editor to study!

Basic arithmetic operator

The operators used for basic arithmetic operations in C language are: +, -, *,%, /. The use of these operators is basically the same as you might imagine:

The addition operator "+" causes the values on both sides to be added together.

The subtraction operator "-" subtracts the number before it from the number after it.

Multiplication is represented by "*". The C language does not have a square function, nor does it have an exponential operator. But you can use multiplication to calculate the square.

The symbol "%" indicates surpluses. The result of the remainder operation is the remainder after the division of two numbers. Therefore, the value participating in the operation must be an integer.

The symbol "/" indicates division. Note that division of the floating-point type yields a floating-point result, while integer division yields an integer result.

For example, the result of 5Accord 2 is 2. When you mix integers and floating-point numbers, the result is floating-point numbers, such as 2.5 for 5-hand 2.0.

Take a look at an example:

C code

# include

Int main (void)

{

Int a = 7

Int b = 3

/ / find the remainder of a divided by b and output the remainder

/ / write your code here

Printf ("% d", a% b)

Return 0

}

At this point, the study of "what are the basic arithmetic operators in C language" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report