C Language Learning Tutorial Chapter II-Data types, operators, expressions (eight)

Source: Internet
Author: User
Tags arithmetic operators character set constant logical operators variables

Comma operator
The comma "," in C language is also an operator, called a comma operator. Its function is to connect two expressions together to form an expression called a comma expression.
The general form is: expression 1, Expression 2 Its evaluation procedure is to find the value of two expressions, and the value of the expression 2 as the value of the entire comma expression.
void Main () {
int a=2,b=4,c=6,x,y;
X=a+b,y=b+c;
printf ("y=%d,x=%d", y,x);
}
a<--2,b<--4,c<--6,x<--0,y<--0
x<--a+b,y<---B+c
In this case, Y equals the value of the entire comma expression, which is the value of expression 2, and X is the value of the first expression. For a comma expression, two points are also indicated:
1. Expression 1 and Expression 2 in the general form of a comma expression can also be comma-expressed. For example: expression 1, (expression 2, expression 3) forms a nested case. So you can extend the comma expression to the following form: expression 1, expression 2, ... Expression n the value of the entire comma expression equals the value of the expression N.
2. A comma expression is used in a program, usually to separate the values of expressions within a comma expression, and not necessarily the value of an entire comma expression.
3. It is not a comma expression in all places where commas appear, as in variable descriptions, the comma in the function parameter table is used only as a spacer between the variables.
[Practice]//arithmeticint a,b,c;
float D;
a=11;
b=235;
C=a+b-a*b;
D= (float) (float) A;
a=c/a; ' Vtable
a,2,0
b,2,0
c,2,0
d,4,0.0
of Vtable
' Vupdate
1,0;2,0;3,0
4,0.0
1,11
2,235
3,-2339
4,-212.636368
1,-212
of Vupdate
of Practice
[Practice]//1int a,b,c1,c2;
a=25;
b=3243;
c1=b/a;
c2=b%a; ' Vtable
a,2,0
b,2,0
c1,2,0
c2,2,0
of Vtable
' Vupdate
1,0;2,0;3,0;4,0
1,25
2,3243
3,129
4,18
of Vupdate
of Practice
[Practice]//1int a,b,c;
a=25;
b=40;
c=a+b,c+35; ' Vtable
a,2,0
b,2,0
c,2,0
of Vtable
' Vupdate
1,0;2,0;3,0
1,25
2,40
3,65
of Vupdate
of Practice

Summary

1.C data type
Basic type, constructed type, pointer type, empty type
2. Classification and characteristics of basic types
Type descriptor byte numeric range
Character Char 1 c character Set
Basic integer int 2-32768~32767
Short int 2-32768~32767
Long int 4-214783648~214783647
Unsigned type unsigned 2 0~65535
unsigned long int unsigned long 4 0~4294967295
Single-precision real float 4 3/4e-38~3/4e+38
Double type 8 1/7e-308~1/7e+308
3. Constant suffix
L or L long integral type
U or u unsigned number
F or F floating-point numbers
4. Constant type
integers, long integers, unsigned digits, floating-point numbers, characters, strings, symbolic constants, escape characters.
5. Data type Conversion
• Automatic conversion
In the mixed operation of different types of data, the system is automatically transformed from a small byte type to a multibyte type. When different types of quantities are assigned to each other, they are also automatically converted by the system, converting the type to the right of the assignment number to the left type.
• Forced conversions
The conversion is completed by the cast operator.
6. Operator precedence and binding
In general, the precedence operator has a higher priority and the assignment operator has a lower priority. Arithmetic operators have higher precedence, and relational and logical operators have lower precedence. Most operators have left-binding, single-eye operators, triple-mesh operators, assignment
7. Expression type
An expression is a formula that consists of an operator connecting constants, variables, and functions. Each expression has a value and a type. Expression evaluation is performed in the order specified by the precedence and binding of the operators.

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.