Answer:
Explanation:
The following Python program has a function called addDigits which takes a number as a parameter and returns the sum of the digits. Then the program creates a loop that keeps creating random numbers between 222 and 1000 and divides it by the value returned from the function addDigits. If the remainder is 0 is prints out a statement and breaks the loop, ending the program. The picture below shows the output of the program.
import random
def addDigits(num):
sum = 0
for x in str(num):
sum += int(x)
return sum
sum = addDigits(random.randint(222, 1000))
while True:
myRandomNum = random.randint(2, 99)
if (sum % myRandomNum) == 0:
print("No remainder between: " + str(sum) + " and " + str(myRandomNum))
break
Answer:
highlight a cell in column A; place your cursor on the border of the cell so it turns into a two sided arrow and drag
Explanation:
y
Answer:
The correct program to this question can be given as:
Program:
//header file
#include<iostream> //include header file
using namespace std;
//main
int main() //defining method main
{
double radius,area=0; //defining variables
double PI=3.14; //defining variable PI and assign value
cout <<"Enter the radius: "; //message
cin >> radius; //input value by user
area = PI * radius * radius; //formula to calculate area
cout << "Area: "<< area << endl; //print area
return 0;
}
Output:
Enter the radius: 3.0
Area: 28.26
Explanation:
In the above program code, a header file is included. In the next line, the main method is defined, which contain three double type variable that is "radius, area, and PI".
- The radius variable is used to take input by the user, and the area variable is to calculate the area of the circle, and the PI is used to hold a constant value, which is "3.14".
- After taking user input in radius variable the area variable has used the formula of the circle, which calculates a value and in the last print, the function uses "cout", that prints area variable value.
Answer: C) spin-lock with test and set
Explanation:
In spinlock, when a thread locks a spinlock then it continuously retrying locking until it succeeds. Spinlock is the lock that cause thread and continuously check that whether the lock are available or not for synchronization.
So that is why spinlock is best synchronization solution as it is not allowing any another thread.
On the other hand, in mutex thread try to lock a mutex and then, it automatically go to sleep mode before locking and immediate allow another thread to run.