I know this is silly, but I'm quite curious to know that is there any speed difference using conditional statement (i.e. for, if, while, do while)
in C++ with braces and without braces.
FYI : I know that without braces only single statement is executed. Also, it is not a good practice to use conditional blocks w/o braces.
But the confusion is about the speed. Suppose we have only a single statement to be executed either in a for loop
of if block
, then which one of the two approaches is faster.
Example:
CASE 1:
if(condition){
only one statement here
}
CASE 2:
if(condition)
only one statement here
Do they really have a difference in their execution time? If yes, which one is faster?