Online Courses
Free Tutorials  Go to Your University  Placement Preparation 
Goeduhub's Online Courses @ Udemy in Just INR 570/-
Online Training - Youtube Live Class Link
0 like 0 dislike
78 views
in Tutorial & Interview questions by Goeduhub's Expert (8.3k points)

Evaluates its left operand, discards the resulting value, and then evaluates its rights operand and result yields the value of its rightmost operand.

Goeduhub's Top Online Courses @Udemy

For Indian Students- INR 570/- || For International Students- $12.99/-

S.No.

Course Name

 Coupon

1.

Tensorflow 2 & Keras:Deep Learning & Artificial Intelligence

Apply Coupon

2.

Natural Language Processing-NLP with Deep Learning in Python Apply Coupon

3.

Computer Vision OpenCV Python | YOLO| Deep Learning in Colab Apply Coupon
    More Courses

1 Answer

0 like 0 dislike
by Goeduhub's Expert (8.3k points)
 
Best answer
Evaluates its left operand, discards the resulting value, and then evaluates its rights operand and result yields the value of its rightmost operand.

int x = 42, y = 42;

printf("%i\n", (x *= 2, y)); /* Outputs "42". */

The comma operator introduces a sequence point between its operands.

Note that the comma used in functions calls that separate arguments is NOT the comma operator, rather it's called a separator which is different from the comma operator. Hence, it doesn't have the properties of the comma operator.

The above printf() call contains both the comma operator and the separator.

printf("%i\n", (x *= 2, y)); /* Outputs "42". */

/*                      ^          ^ this is a comma operator */

/*                      this is a separator */

The comma operator is often used in the initialization section as well as in the updating section of a for loop. For example:

for(k = 1; k < 10; printf("\%d\\n", k), k += 2);   /*outputs the odd numbers below 9/*

/* outputs sum to first 9 natural numbers */

for(sumk = 1, k = 1; k < 10; k++, sumk += k)    

      printf("\%5d\%5d\\n", k, sumk);

3.3k questions

7.1k answers

393 comments

4.5k users

Related questions

0 like 0 dislike
1 answer 64 views
0 like 0 dislike
1 answer 71 views
0 like 0 dislike
1 answer 80 views
0 like 0 dislike
1 answer 77 views

 Goeduhub:

About Us | Contact Us || Terms & Conditions | Privacy Policy || Youtube Channel || Telegram Channel © goeduhub.com Social::   |  | 
...