Your code is legit assuming the variables exist and are within scope
void numberdown() {
if (a > 1) a--;
if (b > 2) b--;
if (c > 3) c--;
if (d > 4) d--;
if (e > 5) e--;
if (f > 6) f--;
}
As mentioned above try to indent correctly, use the space bar of your keyboard and when an if clause is a single statement you don’t need the curly brackets so it makes reading lighter.
thanks... my exact question multiple if statement is correct or if, elseif... else has to be followed.
because i am using numberdown() to only the decrement values inside a to f variables with minimum numbers condition . my doubt is multiple simple if statement is efficient or nested if is efficient .
It depends what you want to do
If you use an else you get one or the other. If you don’t - like above - all the variables get a chance to be decreased.
If your if are needed, then they are needed. Don’t second think this