mardi 27 octobre 2020

what is proper way to use curly arrow in C++?

for(int i = 10 ; b >= i;i++){
        if(i%2 == 0)
            cout << "even" << endl;
        else
            cout << "odd" << endl;
        
    }

for(int i = 10 ; b >= i;i++){
        if(i%2 == 0){
            cout << "even" << endl;
        }else{
            cout << "odd" << endl;
        }
    }

both of these code work with the only difference being the curly brackets for if else statement, just wondering when to use curly brackets and when not to?


Aucun commentaire:

Enregistrer un commentaire