| |
GeekInterview.com > Interview Questions > Programming > C++
| Print | |
Question: Register Relation
Answer: Why p++ is faster than p+1? |
| June 06, 2009 01:08:22 |
#2 |
| tewari2312 |
Member Since: June 2009 Total Comments: 4 |
RE: Register Relation |
p++ when the command p++ is given the compiler understands that value of p is incresed by one and wherever p is used (as in the expression u=p/2) it(compiler) uses value p+1rather than p, so if the code is int p; p++; float u=p/2; then the lines compiler understands is int p; p++; float u=(p+1)/2;
p=p+1 when this statement is written then the compiler goes to the location where p is stored and increments the value by 1 |
| |
Back To Question | |