I m trying to do a while loop that prints out the first x even numbers x being the number i input

0 votes
public static void main(String[] args)
        {
            int num;
        Scanner input = new Scanner(System.in);
        num = input.nextInt();
        
        int i=0;
        while(i<=num)
        {
            System.out.println(num);
            i+=2;
            num+=1;
        }

    }
Apr 1, 2022 in Java by Skulltrooper

edited 5 days ago 8 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP