C++
What will ...
Site Language: English
Українська
English
Русский
Programming Tests
Login
Sign Up
Programming Tests
Theory
Snippets
Papers
Landing
Android
Prices
FAQ
Cosmo Story
Terms and Conditions
Privacy Policy
Cookies Policy
Send Feedback
What will be the value of variable a after the following code is executed?
int а = 7; a /= 2;
3.5
2
3
7
The result is undefined
Code will not compile
Explanation
The compound assignment operator is equivalent to:
a = a / 2;
Since
a
and 2 are of
int
type, then
a/2
will perform an integer division, therefore a/2 = 3.
operators
integer division
compound assignment
basics
Like
Login in
to like
Comment
Login in
to comment
Share
Tweet
C
++
Quiz
Login to learn C++
or
Read more about
C++ Quizzes
Follow CodeGalaxy
Mobile Beta
Send Feedback
Sign Up Now
or
Subscribe for future quizzes
Login in to like
Login in to comment