Answer:
Result is: 65
Explanation:
To analyze this code let us asign line numbers:
- public class Test {
- public static void main( String[] args )
- { int[] a; a = new int[ 10 ];
- for ( int i = 0; i < a.length; i++ )
- a[ i ] = i + 2;
- int result = 0;
- for ( int i = 0; i < a.length; i++ )
- result += a[ i ];
- System.out.printf( "Result is: %d\n", result );
- }
- }
On line 3, an array of ints is created of size 10
On line 4 and 5 a for loop is used to add values to the array. at the end of the execution of line 4 and 5, the array will contain the following elements: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
On line 6 an int variable result is created and initialized to 0
line 7 and 8 allows a for loop through the array adding up all the elements of the array and assigning them to result
Line 9 outputs the value of result (Which is the total sum)
Answer:
Swap codes in line 7 and 8
Explanation:
The code segment below
Line 1: count ← 0
Line 2: sum ← 0
Line 3: FOR EACH value IN numbers
Line 4: {
Line 5: count ← count + 1
Line 6: sum ← sum + value
Line 7: average ← sum / count
Line 8: }
Line 9: DISPLAY (average)
The above code will make the program translator calculate the average value at each iteration.
This will take a longer time to execute and also means more instructions for the program translator.
Swapping line 7 and 8 will reduce the number of instructions to execute. This will have an instant effect on the time taken to execute the program.
Swapping line 7 and 8 means that, the program translator will only calculate the average after it must have finished calculating the sum of the values in the iteration statement.
Energy from sources that can be regenerated or reused is called renewable energy.
Renewable energy is energy that can be replenished on a human timescale like hydro-electric power, solar energy and wind power. Geothermal energy is also considered renewable energy.
Answer: The math module is a standard module in Python and is always available. To use mathematical functions under this module, you have to import the module using import math .
Explanation:
Answer:
Rule based Attack.
Explanation:
As password cracking is a technique used to extract user’s password of application/files without the knowledge of the legitimate user. The attacker can use Rule Based Attack to find the password and to intrude or compromise the network and systems.
This is like a programming language to generate the password. This involves functions to modify, cut, edit and extend the generally used terms by the user.