asked 203k views
0 votes
What kinds of pointer arithmetics are allowed?

A) Addition and subtraction
B) Multiplication and division
C) Bitwise operations
D) All of the above

1 Answer

6 votes

Final answer:

In programming, specifically C and C++, pointer arithmetics that are allowed include addition and subtraction operations. Multiplication, division, and bitwise operations are not permitted with pointers.

Step-by-step explanation:

The question is about what kinds of pointer arithmetics are allowed in programming. In C and C++ languages, pointers can be used with the following arithmetic operations:

  • Addition (+) - You can add an integer value to a pointer, which advances the pointer by a number of elements based on the size of the data type it points to.
  • Subtraction (-) - You can subtract an integer value from a pointer, or you can subtract one pointer from another to get the number of elements between them, provided they point to elements of the same array.

However, multiplication (*) and division (/) are not allowed with pointers, and neither are bitwise operations. Therefore, the correct answer to the question is :

A) Addition and subtraction

answered
User Matt Styles
by
7.9k points