Explanation:
As it progresses high around an atmosphere, the amount of power through each tropic stage reduces. Little enough as 10% including its power is passed towards the next layer at every primary producers; the remainder is essentially wasted as heat by physiological activities.
Answer & Explanation:
//written in java
public class Main {
private static void printOdd(int[] list) {
for (int value : list) {
if (value % 2 == 1) {
System.out.println(value);
}
}
}
public static void main(String[] args) {
printOdd(new int[]{5, 6, 2, 3, 11, 4, 7});
}
}
Answer:
The function definition to this question can be given as:
Function definition:
void printAttitude(int x1) //define function printAttitude.
{
//nested else-if statements
if(x1==1)
//if block
cout<<"disagree"<<endl;
//message
else if(x1==2)
//else if block
cout<<"no opinion"<<endl;
//message
else if(x1==3)
//else if block
cout<<"agree"<<endl;
//message
else
cout<<" ";
}
Explanation:
In the above method definition firstly, we define a method that is "printAttitude". In this method, we pass an integer variable that is "x1". This function does not return any value because its return type is void. In this method, we use nested else-if statements. The description of these conditions can be given as:
- In the if block we check the variable x1 value is equal to 1 If this condition is true. It will print "disagree" otherwise it will go to else-if block.
- In the else-if block, we check the variable x1 value is equal to 2 if the condition is true. It will print "no opinion". otherwise, we will go to another else-if block.
- In this block, we check the variable x1 value is equal to 3 if this condition is true. It will print "agree".otherwise it will go to else block.
- In the else block it will print nothing.
Answer:
- You need to create a variable outside (before) the input loop.
- You need a variable inside your loop that temporarily holds the user input.
- In your loop, you will compare if the variable outside the loop is greater than (or less than) the new user input.
I don't know what program language you are using, but I will use python since it's easy to read and you will get the idea if you're using a different programming language.
<u>Code (Python)</u>
largestnum = 0
for x in range(6): <em>#loops 6 times</em>
newnum = int(input("Enter a number: ")) #ask user for input & converts to int.
if newnum > largestnum: <em>#if new number is greater than largest num </em>
largestnum = newnum <em>#make it the largest number</em>
<em> </em>print("Largest:", largestnum)
The reason why you need a variable outside of the loop is because after the loop is done all variables inside the loop are trashed and can no longer be accessed outside of the loop.