menu
QAmmunity.org
Login
Register
My account
Edit my Profile
Private messages
My favorites
Ask a Question
Questions
Unanswered
Tags
Categories
Ask a Question
What does the following algorithm do? public static void mystery(int nums[]) { for (int i = 0; i < nums.length; i++) { if (nums[i] % 2 != 0) nums[i]++; } } 1. Adds 1 to every value in the array. 2. Tests if the elements in the array are even or odd. 3. Changes all the values in the array to even numbers. 4. Doubles all the values in the array. 5. Doubles every other value in the array.
asked
Aug 4, 2018
127k
views
5
votes
What does the following algorithm do?
public static void mystery(int nums[]) {
for (int i = 0; i < nums.length; i++) {
if (nums[i] % 2 != 0)
nums[i]++;
}
}
1. Adds 1 to every value in the array.
2. Tests if the elements in the array are even or odd.
3. Changes all the values in the array to even numbers.
4. Doubles all the values in the array.
5. Doubles every other value in the array.
Computers and Technology
high-school
Daniel Slater
asked
by
Daniel Slater
8.5k
points
answer
comment
share this
share
0 Comments
Please
log in
or
register
to add a comment.
Please
log in
or
register
to answer this question.
2
Answers
5
votes
2. Tests if the elements in the array are even or odd.
Scepticalist
answered
Aug 5, 2018
by
Scepticalist
8.1k
points
ask related question
comment
share this
0 Comments
Please
log in
or
register
to add a comment.
4
votes
The purpose of the program code is to change each value into an even number. If the number is even already, it does not change the number. If the number is odd, it will add one and change it to an even number.
Kishma
answered
Aug 10, 2018
by
Kishma
8.0k
points
ask related question
comment
share this
0 Comments
Please
log in
or
register
to add a comment.
← Prev Question
Next Question →
Related questions
asked
Dec 16, 2024
50.3k
views
What is the purpose of the code snippet given below? static void Main() CArray nums = new CArray(); Random rnd = new Random(100); for(inti=0;i<10;i++) nums.Insert((int)(rnd.NextDouble() * 100)); nums.DisplayElements();
Udan
asked
Dec 16, 2024
by
Udan
8.2k
points
Computers and Technology
high-school
1
answer
2
votes
50.3k
views
asked
Feb 27, 2018
147k
views
Consider the following methods: public static double average(int nums[]) { int sum =0; for (int i = 0; i < nums.length; i++) { sum += nums[i]; } return (1.0 * sum) / nums.length; } //average public static int[] mystery(String a[]) { int temp [] = new int[a.length]; for (int i = 0; i < a.length; i++) { temp[i] = a[i].length(); } return temp; } //mystery What is output by running the following? String spelling[] = {"against", "forms", "belief", "government", "democratic", "movement", "understanding", "single", "followed", "scenario"}; System.out.println( average( mystery(spelling))); 1. 10 2. 8.5 3. 8.1 4. Error, you cannot average Strings. 5. 8
Rani
asked
Feb 27, 2018
by
Rani
7.6k
points
Computers and Technology
high-school
1
answer
4
votes
147k
views
asked
Jan 13, 2022
204k
views
Write the recursive method printNumber. The public static method named printNumber takes two parameters. The first parameter is an integer array called nums, and the second is parameter is an even int
RidRoid
asked
Jan 13, 2022
by
RidRoid
8.0k
points
Computers and Technology
college
1
answer
0
votes
204k
views
Ask a Question
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.
9.5m
questions
12.2m
answers
Other Questions
The book shows how to add and subtract binary and decimal numbers. However, other numbering systems are also very popular when dealing with computers. The octal (base 8) numbering system is one of these.
Seven basic internal components found in a computer tower
describe an advance in technology that makes life more enjoyable. what discoveries contribute to this technology?
Explain why binary codes are used to represent characters, numbers and symbols :)
What is an example of a dedicated computer system?
Twitter
WhatsApp
Facebook
Reddit
LinkedIn
Email
Link Copied!
Copy
Search QAmmunity.org