What are the roots of the quadratic function f(x)=x^2+2x+1?
Put f(x) in the formula for quadratic roots, A=1 , B=2, C=1, so: x1,2=(-B+-sqrt(B^2-4*A*C))/2*A => x1,2=(-2+-sqrt(4-4))/2, => x1=x2=-1 The given function has 2 real roots and they are both -1.
Josh has $200 in his wallet. How much money will he have if he puts another $600 in his wallet?
The solution is to sum up the amount of money he had before putting $600 in his wallet with the $600, so, $200 + $600 = $800. The answer is : Josh has $800 in his wallet.
What is the difference between for and while loops?
For loop is (often) being used when you know how many iterations of the loop you will have, and while loop is more often used when you don't know how many iterations of the loop you will have.