Computer Science, asked by Shreeraksha1130, 1 year ago

Which of the following is/are correct way(s) to increment variable p? Tick all correct answer(s). No partial marks and no negative marks. Select one or more: ++p p+ p=p+1 p++

Answers

Answered by mukeshkd721
1

++p p=p+1 p++ are the correct ways to increment p

++p is used for pre-increment

p++ is used for post increment

p=p+1 is also for post increment


Answered by Sidyandex
1

The right way to increment variable p is ++p p=p+1 p++

++p is used to increment before (prefix)

P++ is used to increment later (postfix)

P=p+1 is to increment later.

Basically, ++ operator is used to increment the value of the variable by 1.

This operator can be used either as a prefix or as a postfix.

When it is prefix, the value is increment first and then its actual value appears where in with postfix, the actual value is returned and then it is incremented by 1.

Similar questions