Using while loop I want to print the first x even numbers x being the user input

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

    }
Apr 5, 2022 in Java by Skulltrooper

edited 5 days ago 6 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