Answer:
Written using Python 3:
<em>num1 = int(input("Enter first value: "))
</em>
<em>num2 = int(input("Enter second value: "))
</em>
<em>
</em>
<em>finalResult =(num1+num2) / 3
</em>
<em>print("Answer is: ", finalResult)</em>
<em />
INPUT:
Enter first value: 4
Enter second value: 5
OUTPUT:
Answer is: 3
Explanation:
First step is to declare the variables:
Second is to ask for an input:
- input("Enter first value: ")
Then we need to convert them into integers by encapsulating the line above inside int(). This is a requirement before you can do any mathematical operations with the given values.
- num1 = int(input("Enter first value: "))
Next is to calculate:
- <em>finalResult </em><em>=(num1+num2) / 3
</em>
- Here we first add the values of num1 and num2, <em>then </em>divide the sum by 3.
And to test if the output is correct, let us print it:
- <em>print("Answer is: "</em><em>,</em><em> </em><em>finalResult</em><em>)</em>
- print() - when used for strings/texts, use quotation marks like: "text here"
- but when used to print variables and numbers (integers, floats, etc), there is no need to enclose them with quotation marks.
- to concatenate string and an integer (in this case the variable finalResult), simply add a comma right after the string.
<em />
Complete Question:
Write code that prints: Ready! userNum ... 2 1 Blastoff! Your code should contain a for loop. Print a newline after each number and after each line of text Ex: userNum = 3 outputs: Ready! 3 2 1 Blastoff!
Answer:
public class TestClock {
public static void main(String[] args) {
int userNum= 3;
System.out.print("Ready! "+userNum+" ");
for (int i=userNum;i>1; i--){
userNum--;
System.out.print(userNum+" ");
}
System.out.println("Blasoff!");
}
}
Explanation:
- Create and initialize userNum
- Use System.out.print to print the sequence ("Ready! "+userNum+" ") on same line
- use for statement with this condition for (int i=userNum;i>1; i--) decremeent userNum by 1 after each loop iteration and print userNum on same line
- outside the for loop print "Blasoff!"
Is this dealing with the computer because I can help you then
One factor affecting digital camera quality is the number of pixels, measured in megapixels, use to store the data for each image.
Answer:
See explaination
Explanation:
#include<iostream>
#include<stack>
#include <algorithm> // std::make_heap, std::pop_heap, std::push_heap, std::sort_heap
#include <vector> // std::vector
using namespace std;
void StaticArray()
{
unsigned int array[64536];
for(unsigned int i=0;i<64536;i++)
array[i]=i;
}
void Stack()
{
stack<unsigned int> mystack;
for(unsigned int i=0;i<64536;i++)
mystack.push(i);
}
void Heap()
{
unsigned int myints[64536];
for(unsigned int i=0;i<64536;i++)
myints[i]=i;
vector<unsigned int> v(myints,myints+64535);
make_heap (v.begin(),v.end());
push_heap (v.begin(),v.end());
}
int main()
{
StaticArray();
Stack();
Heap();
return 0;
}