Answer:
Each array position holds the position from which the information is going to be retrieved. After the code is run, each position will have the information retrieved from that position.
Explanation:
The best way to solve this problem is working as if we had a very small array. Then we can generalize for the large array.
For example
int a[3];
a[0] = 1; a[1] = 2; a[2] = 0;
for(i = 0; i < 3; i++)
a[i] = a[a[i]];
When i = 0, we have:
a[i] = a[a[i]] = a[a[0]] = a[1] = 2;
When i = 1, we have
a[i] = a[a[i]] = a[a[1]] = a[2] = 0;
When i = 2, we have
a[i] = a[a[i]] = a[a[2]] = a[0] = 1;
Basically, in our small example, each array position holds the index from which we are going to retrieve the information. The same is going to happen in the array of length 99. After the code is run, each position will have the information retrieved from that position
Answer:
int main()
{
int A1= {5,3,4,8,9,0,7};
int SArri1 = sizeof(A1);
printf("Original array: ");
for (int i=0; i < SArri1;i++)
printf("", A1[i] );
int i, sum = 20, n= 0;
printf("\nArray pairs whose sum equal to 20: ");
for (int i=0; i<SArri1; i++)
for (int j=i+1; j<SArri1; j++)
if (A1[i]+A1[j] == sum)
{
Printf(“\n”, array1[i])
Printf(“,”,array1[j]);
n++;
}
printf("\nNumber of pairs whose sum equal to 20: ",n)
return 0;
}
Explanation:
First of all, you should create the array of integers, and put random numbers. Then you have to save in a constant the size of the array (in this code is called SArr1) With a for you can print all the numbers that are on the array because then you will print all array pairs whose sum is equal to a specified numer. in this code we are going to use 20.
then with a condition (if) you are going to compare one of number of the array with all the others and check if its equal to 20. If yes, it going to print the numbers that answer to that condition and it's going to add +1 to the variable n (for this you will need to use two bucles for)
Then you can print the number of pairs whose sum is equal to 20 by printing n
Answer:
int miles[4] = {1, 5, 9, 22};
Explanation:
Given:
Initialized values = 1, 5, 9, and 22
Find:
Defines an array of four integers
Computation:
int miles[4] = {1, 5, 9, 22};
import java.util.Scanner;
public class JavaApplication41 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String language = scan.nextLine();
if (language.toLowerCase().equals("java")){
System.out.println("Awesome!");
}
else if (language.toLowerCase().equals("python")){
System.out.println("A very simple language!");
}
else if (language.toLowerCase().equals("ruby")){
System.out.println("Are you sure?");
}
else if (language.toLowerCase().equals("javascript")){
System.out.println("Easy enough");
}
else if (language.toLowerCase().equals("c")){
System.out.println("Cool!");
}
}
}
I hope this helps!
million pairs per week.
Answer:
In this case, the country that produces rye will produce 24 million bushels per week, and the country that produces jeans will produce 64 million pairs per week.
Explanation:
Total labor hour = 4 million hour
Number of bushes produce in 1 hour = 6
⇒total bushes produce = 6*4 = 24 million
∴ we get
The country that produces rye will produce 24 million bushels per week
Now,
Total labor hour = 4 million hour
Number of pairs produce in 1 hour = 16
⇒total bushes produce = 16*4 = 64 million
∴ we get
The country that produces jeans will produce 64 million pairs per week.
Answer:
21 times
Explanation:
Following are the description of output:
5 dequeue operations
6 enqueue operations
10 dequeue operations
8 enqueue operations
2 dequeue operations
3 enqueue operations
Last = 10
Answer:
10
Explanation:
An enqueue operation is a function that adds an element(value) to a queue array. A dequeue operations removes an element from a queue array. Queue arrays follow a first-in-first-out approach, so elements that are first stored in the queue are removed/accessed first(enqueue operations add elements at the rear of the queue array).
The following operations leave 10 elements in the queue of array size 12 after its done:
10 enqueue operations= adds 10 elements
5 dequeue operations= removes 5 elements( 5 elements left in queue)
6 enqueue operations= adds 6 elements(11 elements in queue)
10 dequeue operations= removes 10 elements(1 element left in queue)
8 enqueue operations= adds 8 elements(9 elements in queue)
2 dequeue operations= removes 2 elements(7 elements left in queue)
3 enqueue operations= adds 3 elements(10 elements in queue)
Therefore there are 10 elements in the queue after enqueue and dequeue operations.