Repetition Control Statement (While Loop)

PHOTO EMBED

Mon Apr 19 2021 01:24:47 GMT+0000 (Coordinated Universal Time)

Saved by @ahmedqgqgq #java

import java.util.Scanner;
import javax.swing.SwingConstants;
public class Mohamed {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        while (true) {//just take (true) or (false)
            System.out.println("hello ahmed");
        }
    }
}
import java.util.Scanner;
import javax.swing.SwingConstants;
public class Mohamed {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int count = 1;
        while (count <= 5) {
            System.out.println("HI");
            count++;
        }
    }
}
import java.util.Scanner;
import javax.swing.SwingConstants;
public class Mohamed {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int count = 1;
        while (count <= 5) {
            System.out.println("HI");
            ++count;
        }
        System.out.println("count = " + count);
    }
}
import java.util.Scanner;
public class Mohamed {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int count = 5;
        while (count >= 1) {
            System.out.println("HI");
            count--;
        }
        System.out.println("count = " + count);
    }
}
import java.util.Scanner;
public class Mohamed {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int count = 5;
        while (count >= 1) {
            System.out.println("HI");
            count = count - 2;//count-=2
        }
        System.out.println("count = " + count);
    }
}
import java.util.Scanner;
public class Mohamed {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int count = 1;
        while (count <= 5) {
            System.out.println("Hi");
            // ++count;
        }
    }
}
import java.util.Scanner;
public class Mohamed {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int count = 1;
        while (count++ <= 5) {
            System.out.println("Hi #" + count);
            // ++count;
        }
    }
}
import java.util.Scanner;
public class Mohamed {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int count = 1;
        while (count++ <= 5) {
            System.out.println("Hi #" + count);
            // ++count;
        }
        System.out.println("count=" + count);
    }
}



content_copyCOPY