+ 1

What is the meaning of compound operator '*=' in C? What function does it performs.

Ex. int i=2, a; a *= i; printf("%d", a) ;

4th Mar 2019, 9:07 AM
Kunal Kumar
Kunal Kumar - avatar
7 Réponses
+ 3
Since, the value of a is not assigned depending upon the compiler its value can be set to either 0 or some garbage value. So the new value of a is value of ("a" assigned) *(i)
4th Mar 2019, 1:40 PM
Ragan Murali Pasupuleti
Ragan Murali Pasupuleti - avatar
+ 2
With C you will get 16. In Java it will be an error because 'a' don't have value.
4th Mar 2019, 10:33 AM
M_N
+ 1
most likely multiply
4th Mar 2019, 9:53 AM
Matthew Li
Matthew Li - avatar
+ 1
i *= 2; is equal to i = i * 2;
4th Mar 2019, 10:19 AM
M_N
0
Ya. But what would be the output of my example code?
4th Mar 2019, 10:21 AM
Kunal Kumar
Kunal Kumar - avatar
0
This means that a has been assigned the value 8?
4th Mar 2019, 12:50 PM
Kunal Kumar
Kunal Kumar - avatar
0
Thank you
4th Mar 2019, 2:30 PM
Kunal Kumar
Kunal Kumar - avatar