Answer:
a) The exact starting address for Job Q is 43008 bytes
b) The size of the memory block is 46080 bytes
c) Resulting fragmentation is external
Explanation:
a) Job Q starting address
42 k ⇒ 42 × 1024 = 43008.
b) memory block has 3 k in fragmentation ∴ the size of the memory block is calculated as 3 k ⇒ 3 × 1024 = 3072.
The fact that it is a block means that we have end address = 3072 + 43008 = 46080.
c) External Fragmentation: It will come in a system that uses the relocatable dynamic partitions scheme.
write a program that takes in a positive integer as input, and output a string of 1's and 0's representing the integer in binary. for an integer x; the algothm is as long as x is greater than 0 output x % (remainder is either 0 or 1 . x=x/2 in coral language
Answer: Provided in the explanation section
Explanation:
The full questions says:
write a program that takes in a positive integer as input, and output a string of 1's and 0's representing the integer in binary. for an integer x; the algothm is as long as x is greater than 0 output x % (remainder is either 0 or 1 . x=x/2 in coral language. Note: The above algorithm outputs the 0's and 1's in reverse order.
Ex: If the input is:
6
the output is:
011
CODE:
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
while (n > 0) {
printf("%d", n % 2);
n /= 2;
}
printf("\n");
return 0;
}
2
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
while (n > 0) {
printf("%d", n % 2);
n /= 2;
}
return 0;
}
cheers i hope this helped !!
Write a program that prompts the user to input five decimal numbers. The program should then add the five decimal numbers, convert the sum to the nearest integer, and print the result.Use the static_caststatement with an appropriate equation to convert the sum to an integer. Compile and run your program with the following test data:Case 1: Input: 5.1, 5.1, 5.1, 5.1, 5.1. Expected Output: 26.Case 2: Input: 5.0, 5.0, 5.0, 5.0, 5.0. Expected Output: 25
Answer:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double num1, num2, num3, num4, num5, sum = 0;
cout << "Input: ";
cin >> num1 >> num2 >> num3 >> num4 >> num5;
sum = num1 + num2 + num3 + num4 + num5;
cout << "Output: " << static_cast<int>(round(sum)) << endl;
return 0;
}
Explanation:
Include cmath to use the round function
Declare the variables
Get the five numbers from the user
Sum them and assign the result to the sum
Round the sum using the round function, and convert the sum to an integer using static_cast statement
Print the sum
Write a script called checkLetter.sh Review Greeting.sh for an example. Use a read statement and ask user to "Enter A, B, or C: "
If user types A, echo "You entered A"
If user types B, echo " You entered B"
If user types C, echo " You entered C"
Use the case structure to test the user’s string.
If user types any letter from lower case ‘a through z’ or upper case ‘D through Z’, echo "You did not enter A, B, or C".
Answer:
The code is given as below: The input and output is as given for one case.
Explanation:
echo -e "Enter A, B or C : \c" #Printing the line on the screen
read -rN 1 test #read the character in the variable test
echo
case $test in #Setting up the case structure for variable test
[[:lower:]] ) #checking all lower case letters
echo You did not enter A, B or C;;
[D-Z] ) #checking upper case letters from D to Z
echo You did not enter A, B or C;;
A ) #Condition to check A
echo You entered A;;
B ) #Condition to check B
echo You entered B;;
C ) #Condition to check C
echo You entered C;;
esac #Exiting the case structure