Which of the following loops would print out a list of odd numbers between 1 and 10? (Select all that apply.) for (int n

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Which of the following loops would print out a list of odd numbers between 1 and 10? (Select all that apply.) for (int n

Post by answerhappygod »

Which of the following loops would print out a list of odd
numbers between 1 and 10? (Select all that apply.)
for (int num = 1; num<10; num++) {
if (num%2 == 0)
System.out.println(num);
}
int num = 1;
while (num <= 10){
if (num%2 == 0)
System.out.println(num);
num++;
}
int num = 1;
while (num <= 10){
if (num%2 == 1)
System.out.println(num);
num++;
}
int num = 10;
while (num <= 10){
if (num%2 == 1)
System.out.println(num);
num--;
}
for (int num = 1; num<=10; num++) {
if (num%2 == 1)
System.out.println(num);
}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply