Answer:
public class Brainly
{
public static void main(String[] args)
{
BinaryConverter conv = new BinaryConverter();
String binStr = "01001101";
System.out.print(binStr + " in decimal is "+conv.BinToDec(binStr));
}
}
public class BinaryConverter
{
public int BinToDec(String binStr)
{
int d = 0;
while(binStr.length() > 0)
{
d = (d << 1) + ((binStr.charAt(0) == '1') ? 1: 0);
binStr = binStr.substring(1);
}
return d;
}
}
Explanation:
The program "eats" the string from left to right, and builds up the integer representation in variable "d" on the go. While there are digits left, it shifts the previous result to the left and sets the least signficant bit to 1 only if the corresponding string character is a 1.
Answer:
C code for half()
#include<stdio.h>
void half(float *pv);
int main()
{
float value=5.0; //value is initialized
printf ("Value before half: %4.1f\n", value); // Prints 5.0
half(&value); // the function call takes the address of the variable.
printf("Value after half: %4.1f\n", value); // Prints 2.5
}
void half(float *pv) //In function definition pointer pv will hold the address of variable passed.
{
*pv=*pv/2; //pointer value is accessed through * operator.
}
- This method is called call-by-reference method.
- Here when we call a function, we pass the address of the variable instead of passing the value of the variable.
- The address of “value” is passed from the “half” function within main(), then in called “half” function we store the address in float pointer ‘pv.’ Now inside the half(), we can manipulate the value pointed by pointer ‘pv’. That will reflect in the main().
- Inside half() we write *pv=*pv/2, which means the value of variable pointed by ‘pv’ will be the half of its value, so after returning from half function value of variable “value” inside main will be 2.5.
Output:
Output is given as image.
B. forum
they hold the most accurate information and people respond the most
Answer:
Yes, it is correct. God is great. He gives pain but gives the ointment as well to get rid of it. God gives tougher challenges, but God also gives the guts to tackle them and win them. The story of adaptation, ad predator also goes like this. God gives spines to sea urchins to survive, and it gives the birds stronger beaks to break shells. Similarly, he gives programmers awesome brains to solve the toughest problems.
Explanation:
Please check the answer.
Answer:
See explanation below
Explanation:
Previos concepts
First Come First Serve (FCFS) "is an operating system scheduling algorithm that automatically executes queued requests and processes in order of their arrival".
Shortest job next (SJN), or the shortest job first (SJF) or shortest "is a scheduling policy that selects for execution the waiting process with the smallest execution time".
Shortest remaining time (SRF) "is a scheduling method that is a preemptive version of shortest job next scheduling'".
Round robin (RR) is an algorithm where the time parts "are assigned to each process in equal portions and in circular order, handling all processes without priority"
Solution for the problem
Assuming the dataset given on the plot attached.
Part a
For this algorithm the result would be:
Job A 0-6
Job B 6-(6+3) = 6-9
Job C 9-(9+1) = 9-10
Job D 10-(10+4) = 10-14
Part b
For this algorithm the result would be:
Job A 0-6
Job C 6-(6+1) = 6-7
Job B 7-(7+3) = 7-10
Job D 10-(10+4) = 10-14
Part c
For this algorithm the result would be:
Job A 0-1 until 14
Job B 2-(2+3) = 2-5
Job C 3-(3+2) = 3-5
Job D 9-(9+5) = 9-14
Part d
For this algorithm the result would be:
Job A 0-2 , 7-9, 12-14
Job B 2-4, 9-10
Job C 4-(4+1) = 4-5
Job D 5-7, 10-12