Comma operator and comma expression

Source: Internet
Author: User
1 # include <stdio. h> 2 int main () 3 {4 int A = 5; 5 A = (a = 3*5, a * 4), a + 5; 6 printf ("A = % d \ n", a); 7 int B = 5; 8 B = (B = 3*5, B * 4 ), B + 5); 9 printf ("B = % d \ n", B); 10 return 0; 11}

A = 60;

B = 20;

Expression 1, expression 2, expression 3, ------ expression N;

The evaluation process is to first obtain the value of N expressions from left to right, and take the value of N expressions as the value of the whole expression. If there are Parentheses, the values in the brackets are calculated first. The calculation level of the comma expression is the lowest, and the priority of the value assignment operator is higher than that of the comma expression.

First Statement

First a = 15, then, a = 60;

The second formula

B = 15 first, because no value is assigned to the result of the brackets

B = (B = 15,60), B + 5 );

B = (60, 20 );

B = 20;

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.