samedi 29 mai 2021

why does not if command in while loop is not executing?

public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
int n = sc.nextInt();
for(int i = 0 ; i<n ; i++) {
    
    int a =sc.nextInt();
    while (a < 0) {
        int lastDigit = a%10 ;
        a =  a/10;  

// this step is not executing if ( lastDigit == 4) {

            System.out.println("why this is not printing");
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire