menu
Qamnty
Login
Register
My account
Edit my Profile
Private messages
My favorites
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…
Ask a Question
Questions
Unanswered
Tags
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…
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 & Tech
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 & Tech
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 & Tech
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 & Tech
college
1
answer
0
votes
204k
views
Ask a Question
Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.
Categories
All categories
Mathematics
(3.7m)
History
(955k)
English
(903k)
Biology
(716k)
Chemistry
(440k)
Physics
(405k)
Social Studies
(564k)
Advanced Placement
(27.5k)
SAT
(19.1k)
Geography
(146k)
Health
(283k)
Arts
(107k)
Business
(468k)
Computers & Tech
(195k)
French
(33.9k)
German
(4.9k)
Spanish
(174k)
Medicine
(125k)
Law
(53.4k)
Engineering
(74.2k)
Other Questions
“What does it mean when we “rework” copyrighted material?”
Seven basic internal components found in a computer tower
Please help me ! All you do is just put it it all in your own words ! Please this is for my reported card!i don't know how to put it in my own words because my English is not that good!
Twitter
WhatsApp
Facebook
Reddit
LinkedIn
Email
Link Copied!
Copy
Search Qamnty