"C Language-Learning Summary" 01-operator

Source: Internet
Author: User
Tags arithmetic operators

first, the basic Operation1. Arithmetic Operators

A. + addition operator

B.-Subtraction operator

C. * Multiplication operator

D./division operator //Divide two integers, the result is an integer.

E.% take-out operator (modulo operation) //NOTE: 1.  % is an integer 2 on both sides. The positive and negative results of the residual result are only related to the value on the left of%.  

  Expand the knowledge point:

(1) Automatic type conversion

(2) Forced type conversion

(3) Automatic type promotion

1 //Code Demo:2 34     //divide two integers5int a =7/3;//The result is: 26 7     //% the positive and negative results of the residual result are only related to the value on the left of%8     intb =-7%3;//The result is:-19     intc =7%3;//The result is: 1Ten  One    //Automatic type conversion (Double->int) A     intA =10.8; -  -     //coercion type conversion (Double->int) the     intB = (int)10.5; -  -     //Automatic type lift (int->double) -     Doublec =10.6+6;

2. Relational operators

A. < less operator

B. > Greater than operator

C. <= less than equals operator

D. >= greater than equals operator

E. = = equals operator

F.! = does not equal operator

Note:(1) The result of the relational operation is "true"(for example, 7>=3), return 1 , or "false"(e.g. 7<3), return 0 .

            (2) in C , there is no Boolean type, and any value other than 0 is true, and only 0 is false.

//Code Demo:        intA =Ten; //Judging by the results of the relational operation    if(Ten= = a)//Write not recommended: a = = 0;{printf ("conditions established"); }     Else{printf ("conditions are not tenable"); }            

"C Language-Learning Summary" 01-operator

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.