A simple question for the C language

Updated on technology 2024-02-09
8 answers
  1. Anonymous users2024-02-05

    It's nonsense to say so much above. Landlord please see: pay attention to your program: printf("%d,%d",(a,b),(b,a);

    To tell you, (a,b) is the parenthesis operation in C, and its value is the rightmost value of the parentheses, which has nothing to do with the previous ones, for example, (3,4,5,6,7,8) has a value of 8The printf statement in your program prints values b and a, so it's 4 and 3.

    if printf("%d,%d",a,b); Then the values are 3 and 4.

    I just learned to play C language, and I was asked if there was anything I didn't understand.

  2. Anonymous users2024-02-04

    To put it simply.

    That is, the value of the comma expression is the value of the last expression!!

  3. Anonymous users2024-02-03

    a=3,b=4,execute "printf("%d,%d",(a,b),(b,a));

    a, b) and (b, a) This is a comma expression test, the value of the comma expression is the value of the number after the last comma, for example, (a, b) the value of the last comma is b, and the value of (a, b) is the value of b 4

  4. Anonymous users2024-02-02

    Comma operator" , "It is enclosed in parentheses, and its rules of operation are the same as normal operations, but the result is the value of the last expression, e.g. a=(3,5,6,7) The result is a=7In e.g. a=(24,89,45); Result a=45;

    looking at a=(4,a=10,a+4); The result is a=14;

  5. Anonymous users2024-02-01

    Do you write like this to work, what do you want to do, what kind of result do you want to get.

  6. Anonymous users2024-01-31

    You don't set the straight of A and the straight of B to subtract or add, you only give A and B a and B a straight, of course, only show the result of A and B! ''If you add.

    a=3,b=4,c;

    c=a+b;

    printf(ā€œ%d,%dā€,c);

    This way you can show a 3+4 straight!

  7. Anonymous users2024-01-30

    The comma operator knows no???

    The general forms of comma expressions are: Expression 1, Expression 2, Expression 3, ......Expression n

    The process of solving a comma expression is to calculate the value of expression 1 first, and then the value of expression 2 ,......Evaluates all the way up to the value of expression n. Finally, the value of the entire comma expression is the value of the expression n.

    Take a look at a few examples:

    x=8*2, x*4 * the value of the whole expression is 64, and the value of x is 16*

    x=8*2, x*4), x*2 * the value of the whole expression is 128, and the value of x is 16*

    x=(z=5,5*2) *The whole expression is an assignment expression, its value is 10, and the value of z is 5*

    x=z=5,5*2 * The whole expression is a comma expression, it has a value of 10, and both x and z have a value of 5*

    Comma expressions are not used much, and are usually only used when assigning initial values to cyclic variables. Therefore, not all commas in the program should be regarded as comma operators, especially when the function is called, and the parameters are separated by commas, so the comma is not a comma operator.

  8. Anonymous users2024-01-29

    This is the question about comma expressions.

    a, b) is a

    b, a) is b

    In general, for (Expression 1, Expression 2,......The result of expression n) is the result of expression n.

    So your output is 4 and 3 respectively

Related questions
4 answers2024-02-09

It's not very hard that the tail node next points to null. >>>More

9 answers2024-02-09

Scope. You static char *chh;

static char *ch1;Although the address pointed to by the two pointers does not change, have you ever wondered whether the memory address they point to has been released, char chc[10]; It's local, the function is out, the lifecycle is over, and you're trying to access it with a pointer in void times(). >>>More

7 answers2024-02-09

#include

using namespace std; >>>More

13 answers2024-02-09

Why do people live?

Just saw it from The Reader. >>>More

9 answers2024-02-09

It should be 0It should be a remainder operation.