what is difference between ++i and i+=1 from any point of view

前端 未结 7 549
一个人的身影
一个人的身影 2021-01-03 06:10

This is a question from kn king\'s c programming : a modern approach. I can\'t understand the solution given by him:-

The expression ++i is equivalent to (i          


        
7条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-03 06:16

    Difference between both are: ++ is a unary operator while + is a binary operator.... If we consider execution time: i++ is more faster than i=i+1. No of machine cycles differs to execute the same set of code, thats the reason ++ operators are always prefered for Loops. Refer to this thread for more info

提交回复
热议问题