Answer:
The solution code is written in Java
- public static void checkCommonValues(int arr1[], int arr2[]){
- if(arr1.length < arr2.length){
- for(int i = 0; i < arr1.length; i++){
- for(int j = 0; j < arr2.length; j++){
- if(arr1[i] == arr2[j]){
- System.out.print(arr1[i] + " ");
- }
- }
- }
- }
- else{
- for(int i = 0; i < arr2.length; i++){
- for(int j = 0; j < arr1.length; j++){
- if(arr2[i] == arr1[j]){
- System.out.print(arr2[i] + " ");
- }
- }
- }
- }
- }
Explanation:
The key idea of this method is to repeated get a value from the shorter array to check against the all the values from a longer array. If any comparison result in True, the program shall display the integer.
Based on this idea, an if-else condition is defined (Line 2). Outer loop will traverse through the shorter array (Line 3, 12) and the inner loop will traverse the longer array (Line 4, 13). Within the inner loop, there is another if condition to check if the current value is equal to any value in the longer array, if so, print the common value (Line 5-7, 14-16).
Answer:
A. You can use in place of all face-to-face communication.
Explanation:
Hope this helps
A constructor, member initialization lists and also the default member initializer. Here you see all three (in reality you choose one construct per variable).
class A
{
public:
int x = 0;
A() : x(1)
{
x = 2;
}
};
Answer:
The algorithm is as follows
1. Start
2. Input Apple unit price
3. Input Mango unit price
4. input Tomato unit price
5. Total = Apple Price * 2 + Mango Price * 2 + Tomato Price
6. Display Total
7. End
Explanation:
Start the algorithm
1. Start
The next three lines gets input for the price of each fruit
<em>2. Input Apple unit price</em>
<em>3. Input Mango unit price</em>
<em>4. input Tomato unit price</em>
This calculates the total price
5. Total = Apple Price * 2 + Mango Price * 2 + Tomato Price
This displays the total price
6. Display Total
Stop the algorithm
7. End
Answer:
The process of adding binary numbers is the same as the process adding decimal numbers which are the normal base 10 numbers with the difference being that in decimal numbers there are digits 1 to 9 and in binary numbers, there are only digits 1 and 0
So when we add binary numbers, we havr;
0 + 0 = 0
1 + 0 = 1
0 + 1 = 1
1 + 1 = 10
Why 1 + 1 = 10 is because, there are no 2s in binary number system, just like when we get from 0 to 9 in a decimal system we start again at 10
For binary subtraction, we have the following;
0 - 0 = 0
1 - 0 = 1
1 - 1 = 0
10 - 1 = 1 (from 1 + 1 = 10)
For example 1100₂ - 1010₂ = 0010₂
As shown below
Borrow 1
, ↓
1, 1 ¹0 0
<u> 1, 0 1 0</u>
, 0 0 1 0
The addition and subtraction of the binary number system are similar to that of the decimal number system. The only difference is that the decimal number system consists the digit from 0-9 and their base is 10 whereas the binary number system consists only two digits (0 and 1) which make their operation easier
Explanation: