Answer:
Operating systems work like translators because they are able to take software and hardware, and put it all together to work in a way that is readable and usable for the consumer.
Answer:
Yes, overloading is one of the methods which are popular in programming language. Overloading basically refers to the same function but different signature called function overloading or method overloading. It is the ability to define the multiples method by using the single identifier.
The overloading is important because it has the ability to design the multiple method by using similar name. It also provide the high flexibility to the programmers to call the same method in the data. overloading basically provide the high clarity in the code.
Overloading is used to achieved the compile time polymorphism.
Following are program of function overloading in c++ are:
Class abc // creating class
{
public:
int p;
void fun() // function fun with no parameter/
{
cout<<” hello “;
}
void fun(int a) // function fun with parameter
{
p=a;
cout<<p;
}
};
int main() // main function
{
abc ob; // creating object
ob.fun();// print hello;
ob.fun(6);// print 6
return 0;
}
Explanation:
In this program the function fun() have same name but different signature in the main method we create the object of class abc i.e ob. ob.fun() this statement called the function with no parameter and ob.fun(6) this statement will called the function with integer parameter.
Answer:
No you can not tell that recursion is ever required to solve a problem.
Recursion is required when in the problem, the solution of the input depends on the solution of the subsets of the input.
Iteration is also another form of repetitive approach we follow to solve that kind of problems.
But the difference between recursion and iteration is :
- In recursion we call the function repeatedly to return the result to next level.
- In iteration certain bunch of instructions in a loop are executed until certain conditions met.
Explanation:
For example in the Fibonacci sequence problem, to find , we need to compute and before that.
- In case of recursion we just call the method Fibonacci(n) repeatedly only changing the parameter Fibonacci(n-1), that calculates the value and return it.
Fibonacci(n)
1. if(n==0 or n==1)
2. return 1.
3.else
4. return( Fibonacci(n-1)+Fibonacci(n-1) )
- But in case of iteration we run a loop for i=2 to n, within which we add the value of current and to find the value of
Fibonacci(n)
1. if(n<=2)
2. result = 1
3. else
4. result1 =1 and result2=1.
5. { result = result1 +result2.
6. result1= result2.
7. result2 = result.
8. }
9. output result.
The answer is B. A only. The optimum valve timing is found through experimentation using an engine dynamometer. The timing of the opening and closing of the valves is called valve timing. So the use of dynamometer measures the power output of a machine that is why it can measure the optimum valve timing.
Answer:
- import statistics
- def st_dev(file_name):
- with open(file_name) as file:
- data = file.readlines()
- numList = []
- for x in data:
- numList.append(int(x))
-
- return statistics.pstdev(numList)
- print(st_dev("text1.txt"))
Explanation:
The solution code is written using Python.
To ease the calculation task, we can import Python statistics module to use the pstdev method to calculate the population standard deviation of a list of numbers (Line 1).
Next, create a st_dev function that take single argument file_name (Line 3). In the function, it will open the input file and read the data line by line (Line 4-5). Create a for loop to traverse through each line of the data which is an integer and append it to numList (Line 7-8). We can pass the numList to pstdev method (Line 10) and return the resulting standard deviation value as output.
We test the function by passing a file which hold a list of integer values in each line (Line 12).
8
9
12
11
21
15
16
10
7
13
And the output we shall get is 4.019950248448356