[solved] – Question 79826
What is the value of h(231,8) for the function below?
def h(m,n):
ans = 0
while (m >= n):
(ans,m) = (ans+1,m-n)
return(ans)
Expert Answer
[solved] – Question 79850
Consider the following function h.
def h(n):
f = 0
for i in range(1,n+1):
if n%i == 0:
f = f + 1
return(f%2 == 1)
The function h(n) given above returns True for a positive number n whenever:
n is a multiple of 2
n is a composite number
n is a prime number
n is a perfect square
Expert Answer
[solved] – Question 79863
What does g(31415927) return, for the following function definition?
def g(x):
(q,d) = (1,0)
while q <= x:
(q,d) = (q*10,d+1)
return(d)
Expert Answer
[solved] – Question 79866
What does g(31415927) return, for the following function definition?
def g(x):
(q,d) = (1,0)
while q <= x:
(q,d) = (q*10,d+1)
return(d)
Expert Answer
[solved] – Question 79876
What does g(31415927) return, for the following function definition?
def g(x):
(q,d) = (1,0)
while q <= x:
(q,d) = (q*10,d+1)
return(d)
Expert Answer
[solved] – Question 79878
Find 5 errors in the following program. Rewrite the program.
int main()
(
double temp:
cout<<”Enter temperature:`;
cin>>temp;
if(temp >= 20 && temp <=30)
cout<<”Outdoor Gamen”.
else
cout<”indoor gamen”;
return 0;
}
Expert Answer
[solved] – Question 799
What’s the difference between the constants and the [b]read only[/b] fields in C# program?
Expert Answer
[solved] – Question 79930
Consider the following function f.
def f(m):
if m == 0:
return(0)
else:
return(m+f(m-1))
Which of the following is correct?
The function always terminates with f(n) = n(n+1)/2
The function always terminates with f(n) = factorial of n
The function terminates for non-negative n with f(n) = n(n+1)/2
The function terminates for non-negative n with f(n) = factorial of n
Expert Answer
[solved] – Question 79935
def h(m,n):
ans = 0
while (m >= n):
(ans,m) = (ans+1,m-n)
return(ans)
Expert Answer
[solved] – Question 79938
Write a function intreverse(n) that takes as input a positive integer n and returns the integer obtained by reversing the digits in n.
Here are some examples of how your function should work.
>>> intreverse(783)
387
>>> intreverse(242789)
987242
>>> intreverse(3)
3
Expert Answer

