Home > Backend Development > C++ > body text

The meaning of i+++j in c++

下次还敢
Release: 2024-05-01 11:51:14
Original
605 people have browsed it

i j in C is a suffix auto-increment operator, which represents the following operations: 1. The value of i is first increased by 1 to become i 1. 2. The value of i 1 is then assigned to j, so j's The value also becomes i 1.

The meaning of i+++j in c++

The meaning of i j in C

In C, i j is a suffix The auto-increment operator represents the following operation: The value of

  1. i is first increased by 1 to become i 1.
  2. The value of i 1 is then assigned to j, so the value of j also becomes i 1.

Execution sequence example:

Assume i = 3, j = 5.

  • i j: The value of

    • i is increased by 1, i = 4.
    • 4 Assign value to j, j = 4.

Note:

  • i j is different from i j. The latter increments i by 1 and then adds it to j.
  • i j is also different from i j. The latter first increments i by 1 and then adds i 1 to j.
  • i j can only be used for integer variables.

Sample code:

<code class="cpp">int main() {
  int i = 3;
  int j = 5;

  i+++j;  // i = 4, j = 4

  return 0;
}</code>
Copy after login

The above is the detailed content of The meaning of i+++j in c++. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
c++
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!