Answer:
/*
Find Largest and Smallest Number in an Array Example
This Java Example shows how to find largest and smallest number in an
array.
*/
public class FindLargestSmallestNumber {
public static void main(String[] args) {
//array of 10 numbers
int numbers[] = new int[]{32,43,53,54,32,65,63,98,43,23};
//assign first element of an array to largest and smallest
int smallest = numbers[0];
int largetst = numbers[0];
for(int i=1; i< numbers.length; i++)
{
if(numbers[i] > largetst)
largetst = numbers[i];
else if (numbers[i] < smallest)
smallest = numbers[i];
}
System.out.println("Largest Number is : " + largetst);
System.out.println("Smallest Number is : " + smallest);
}
}
/*
Output of this program would be
Largest Number is : 98
Smallest Number is : 23
*/
Explanation:
Local
----------------------------------------------------
Answer:
Example 1:
def function(num):
print(num*2)
Example 2:
function(5)
num = 2
function(num)
function(3-1)
Explanation:
Given:
See attachment for complete question
To start with Example (1)
def function(num):
print(num*2)
<em>Note that; the above code segment which doubles the parameter, num could have been any other code</em>
<em />
<em>In Example (1), the parameter is num</em>
For example (2):
We can call the function using:
#1. A value:
function(5)
<em>In #1, the argument is 5; a value</em>
#2. A Variable
num = 2
function(num)
<em>In #2, the argument is num; a variable</em>
#3. An Expression
function(3-1)
<em>In #3, the argument is 3-1; an expression</em>