当前位置:网站首页>//1.14 comma operator and comma expression
//1.14 comma operator and comma expression
2022-06-23 01:45:00 【kalada82】
//1.14 Comma operators and comma expressions
#include<stdio.h>
int main(){
int a=2,b=4,c=6,x,y;
y=(x=a+b),(b+c);
printf("y=%d,x=%d",y,x);
return 0;
}
a=3*5,a*4
The solution to this expression , Readers may have two different understandings : One is that “3*5,a*4” Is a comma expression , First find the value of this comma expression , If a The original value of is 3, The value of the comma expression is 12, take 12 Assign to a, So finally a The value of is 12. Another way of thinking :“a=3*5” Is an assignment expression ”,“a*4” Is another expression , The two are connected by commas , Form a comma expression . Which of the two is right ? Assignment operators take precedence over The comma operator , So we should first solve a=3*5( That is the “a=3*5” As an expression ). After calculation and assignment, we get a The value of is 15, And then to solve a*4, have to 60. The value of the entire comma expression is 60.
A comma expression can form a new comma expression with another expression , Such as (a=3*5,a*4),a+5 First calculate a The value is equal to the 15, Proceed again a*4 The operation is 60( but a The value remains the same , Still 15), Proceed again a+5 have to 20, That is, the value of the entire expression is 20.
The general form of comma expression can be extended to
expression 1, expression 2, expression 3…… expression n
边栏推荐
- 10. static member variables, static member methods, and pointers to class members
- JS - single sign on
- MySQL -- how to access the database of a computer in the same LAN (prenatal education level teaching)
- Freshman C language summary post (hold change) Part1 output diamond
- fatal: refusing to merge unrelated histories
- Unique in Pimpl_ PTR compilation errors and Solutions
- Population standard deviation and sample standard deviation
- Branch and loop statements (including goto statements) -part2
- Questions not written in the monthly contest
- Cmake passing related macros to source code
猜你喜欢

2D prefix and

Cmake simple usage

MySQL -- how to access the database of a computer in the same LAN (prenatal education level teaching)

SQL programming task02 job - basic query and sorting

How are pub and sub connected in ros1?

The devil cold rice # 099 the devil said to travel to the West; The nature of the boss; Answer the midlife crisis again; Specialty selection

Browser independent way to detect when image has been loaded

Overview of visual object detection technology based on deep learning

LeetCode 206. Reverse linked list (iteration + recursion)

Wallys/DR7915-wifi6-MT7915-MT7975-2T2R-support-OpenWRT-802.11AX-supporting-MiniPCIe
随机推荐
[cmake command notes]target_ compile_ options
Pat class a 1016 phone bills (time difference)
Why can't I access object properties in a for in loop in an object array
SQL programming task05 job -sql advanced processing
On AI and its future trend | community essay solicitation
Byte order: big endian vs little endian
5. explain function overloading
Foundation Consolidation - Flex width is content width
Development status of full color LED display
Charles garbled code problem solving
A blog allows you to understand the use of material design
Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster
Cmake passing related macros to source code
JS prototype and prototype chain Paramecium can understand
Detailed explanation of clip attribute parameters
LeetCode 206. 反转链表(迭代+递归)
Express framework installation and start service
On function overloading from several examples
Vector 6 (inheritance)
Found several packages [runtime, main] in ‘/usr/local/Cellar/go/1.18/libexec/src/runtime;