samedi 2 janvier 2016

Create a random number and check if it is odd or even

I am looking to create a batch file that, when ran, creates a random integer from 0 to 100 and then runs it through an if statement that checks whether it is odd or even. I've been having some trouble, so here is what I have so far.

@echo off
set /a num=%random% %%100 +1
if ( num % 2 == 0 ) {

//even

}

else

{

    //odd


}




Aucun commentaire:

Enregistrer un commentaire