dimanche 22 septembre 2019

Looking to simplify chain of if statements in C

I need to simplify 4 if statements into something only a few lines for a project.

I can't seem to figure out how to do that.

         if(apple == 1){
             one++;
         }
         if(apple == 2){
             two++;
         }
         if(apple == 3){
             three++;
         }
         if(apple == 4){
             four++;
         }


Aucun commentaire:

Enregistrer un commentaire