Answer:
Following are the program in python language
def prob3_6(k): #function definition
c = 0 #variable declaration
while k != 1: #iterating the while loop
print(k) #print k
if k % 2 == 0:#check if condition
k= k // 2 #divisible by 2
else: #else condition
k = k * 3 + 1
c = c + 1
print(k) #print k
print c #print count
prob3_6(3)#function call
Output:
3
10
5
16
8
4
2
1
7
Explanation:
Following are the description of program
- Create a function "prob3_6" in this function we passing an integer parameter of type "int" named "k".
- Inside that function we declared a variable "c" of type "int" that is used for counting purpose .
- After that we iterated the while for print the value of when it is not equal to 1 .
- We check if condition when k gives 0 on modulus then k is divisible by 2 otherwise else block will be executed in the else part we multiply by 3 to k and add 1 to the k variable .
- Finally print "k" and "c"
Answer:
The answer to this question is given below in the explanation section.
Explanation:
An algorithm is the list of a finite set of instructions and rules that a computer needs to do to complete a task in order to solve a problem.
In short, an algorithm is a series of instructions that are implemented step by step to solve a problem. For example, you could consider a pizza recipe an algorithm for making a pizza in an everyday life routine. But when you are talking about using algorithms in computation and in mathematics. It means that solving a problem using a series of steps step by step.
For example, your everyday tasks aligned on a google calendar and remind you about your tasks using the alarm, etc- how to implement this using set of instructions and rules- is an algorithm.
Solving a quadratic equation is another example of an algorithm.
Binary search, array sorting are an example of an algorithm in computation. Because these algorithms based on the execution of step-by-step instruction to solve a problem such as sorting a list of numbers etc.
Answer:
The correct answer is d) All of these are correct.
Explanation:
ETL stands for Extract, Transform and Load. An ETL system extracts data from the sources, enforces data quality and consistency standards, conforms data so that separated and maybe unrelated sources can be used together, and as a final step delivers data in presentation-ready formats so that developers can build applications and end users can take decisions.
Answer:
if(revenue.cents - expenses.cents < 0){
profit.dollars = revenue.dollars - expenses.dollars - 1;
profit.cents = 1 - revenue.cents - expenses.cents;
}
else{
profit.dollars = revenue.dollars - expenses.dollars;
profit.cents = revenue.cents - expenses.cents;
}
Explanation:
We know that profit is given as: revenue - expenses from the question.
From the given expression above;
if(revenue.cents - expenses.cents < 0)
then profit.dollar will be revenue.dollars - expenses.dollars - 1; the 1 is to be carry over to the cent part. And the profit.cent will be 1 - revenue.cents - expenses.cents;
else the profit.dollars and the profit.cent is computed directly without needing to carry over:
profit.dollars = revenue.dollars - expenses.dollars;
profit.cents = revenue.cents - expenses.cents;