Question

Create a while loop that prints the EVEN numbers between 2-50. Format these numbers such that...

Create a while loop that prints the EVEN numbers between 2-50. Format these numbers such that one number per line.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
C++:
---------
i = 2;
while(i<=50){
    cout<<i<<endl;
    i += 2;
}


C:
---------
i = 2;
while(i<=50){
    printf("%d\n",i);
    i += 2;
}


Java:
---------
i = 2;
while(i<=50){
    System.out.printf("%d\n",i);
    i += 2;
}

Add a comment
Know the answer?
Add Answer to:
Create a while loop that prints the EVEN numbers between 2-50. Format these numbers such that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 2. Create a while loop which starts x at 1, and prints x: “Are we there...

    2. Create a while loop which starts x at 1, and prints x: “Are we there yet?” until x reaches 10. (Don’t forget to Increment x by 1 each while loop). To make things interesting, include the line readline(prompt = "Press [enter] to continue") after the print statement stated above. If x is an even number, print x: “Even Number Encountered” And go to the next iteration of the while loop (i.e. No readline – as above)

  • Create in Java: 1. Create a (nested) for loop that given a number prints a line...

    Create in Java: 1. Create a (nested) for loop that given a number prints a line with the number repeated as many times as the number itself, for example: 22 333 4444 000.- 2.Modify the nested for loop to specify in each line if the numbers are even or odd. For example: 1 (odd) 22 (even) 333 (odd) 4444 (even) Dona.... 3. Modify the nested for loop to only print odd numbers. For example: 333 55555 annan..

  • Write a for loop that prints out all the even numbers between 100 and 2 in...

    Write a for loop that prints out all the even numbers between 100 and 2 in reverse order, i.e., 100, 98, 96, etc. (4 Points) NOTE: Write just the for loop no classes or methods such as main.

  • create a while loop that prints a column of numbers from 1.5 to 3.0 in steps...

    create a while loop that prints a column of numbers from 1.5 to 3.0 in steps of 0.2. Use fprintf

  • Using C++ 1. Create a while loop that counts even numbers from 2 to 10 2....

    Using C++ 1. Create a while loop that counts even numbers from 2 to 10 2. Create a for loop that counts by five (i.e. 0, 5, 10, ...) from 0 to 100 3. Ask for a person's age and give them three tries to give you a correct age (between 0 and 100) 4. Use a for loop to list Celsius and Fahrenheit temperatures. The "C" should be from -20 to 20 and the F should be shown correspondingly...

  • Using R, Create a while loop which starts x at 1, and prints x: “Are we...

    Using R, Create a while loop which starts x at 1, and prints x: “Are we there yet?” until x reaches 10. (Don’t forget to Increment x by 1 each while loop). To make things interesting, include the line readline(prompt = "Press [enter] to continue") after the print statement stated above. If x is an even number, print x: “Even Number Encountered” And go to the next iteration of the while loop (i.e. No readline – as above)

  • Write a while loop that prints all positive numbers that are divisible by 10 and less...

    Write a while loop that prints all positive numbers that are divisible by 10 and less than a given number n. For example, if n is 100, print 10 20 30 40 50 60 70 80 90. import java.util.Scanner; public class PositiveLess {    public static void main(String[] args) {        Scanner in = new Scanner(System.in);        System.out.print("n: ");        int n = in.nextInt();        ...        while (...)        {           ...

  • Use Rstudio 5. Write a repeat() loop that prints all the even numbers from 2 through...

    Use Rstudio 5. Write a repeat() loop that prints all the even numbers from 2 through 10.

  • Labview question: Create a VI using a While Loop that continuously generates random numbers between 0...

    Labview question: Create a VI using a While Loop that continuously generates random numbers between 0 and 1000 until it generates a number that matches a number selected by the user. Determine how many random numbers the VI generated before the matching number. conditions to applied on above problem: 1. Convert the “random number” generator floating point numerical output to integer values to make it easier to find a match. 2. The “user selected number control” should be on the...

  • (java) Write a While loop that prompts the user for only even numbers. Keep prompting the...

    (java) Write a While loop that prompts the user for only even numbers. Keep prompting the user to enter even numbers until the user enters an odd number. After the loop ends, print the sum of the numbers. Do not include that last odd number. You should not store the numbers in an array, just keep track of the sum. Make sure to use a break statement in your code. You may assume that a java.util.Scanner object named input has...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT