In: Computer Science
Correct the code to prints the following:
0 1 2 3 4 5 6 7 8 9
int[] numbers = new int[10];
for(int i=0; i < numbers.length; ++i)
numbers[i] = i * 3;
for(int i=0; i < numbers.length; ++i)
System.out.print(numbers[i] / 2 + 1 + " ");
System.out.println();
Below is the correct code which prints the following:
0 1 2 3 4 5 6 7 8 9
Code:-
import java.io.*;
public class test {
public static void main(String [] args)
{
int[] numbers = new int[10];
for(int i=0; i<numbers.length;
++i)
numbers[i] =
i*2;
for(int i=0; i<numbers.length;
++i)
System.out.print(numbers[i]/2 + " ");
System.out.println();
}
}
Output:-
If you have any doubts please comment will try to solve as soon as possible. Thank you :)