Answer:
Following is the algorithm to interchange the value of two variable x and y.
step 1:Read the two integer x and y.
step 2 :t=x
Step 3: x=y
step 4: y=t
The minimum number of assignment to do this is 3
Explanation:
After reading two integer x & y, create a variable "t" of integer type.
with the help of variable "t", we can swap the value of variable x and y.
It requires 3 assignment to interchange the value.
Answer:
Given
The above lines of code
Required
Rearrange.
The code is re-arrange d as follows;.
#include<iostream>
int main()
{
int userNum;
scanf("%d", &userNum);
if (userNum > 0)
{
printf("Positive.\n");
}
else
{
printf("Non-positive, converting to 1.\n");
userNum = 1;
printf("Final: %d\n", userNum);
}
return 0;
}
When rearranging lines of codes. one has to be mindful of the programming language, the syntax of the language and control structures in the code;
One should take note of the variable declarations and usage
See attachment for .cpp file
Answer: Both have a center for knowledge; motherboard and brain. Both have a way of translating messages to an action. Both have a way of creating and sending messages to different parts of the system.
Answer:
Check the explanation
Explanation:
1.
System = 256Byte = 8 bit
Cache = 64B , block size = 16 byte.
A) Direct Mapped Cache:
Block offset = log (Block size) = log 16 = 4bit
Total # of block inside cache = 4.
Therefore index offset = log 4 = 2bit.
Remaining is tag bits.
Therefore tag bits = 8-(4+2) = 8-6 = 2 bits
Tag Index offset Block offset
(2 bits) (2 bits) (4 bits)
Fully associative cache :
In fully associative cache, any of main memory block can be placed anywhere in cache. Therefore index offset =0 bits.
Therefore tag bits = 8-block offset bit= 8-4 =4bits
Tag Block offset
(4 bits) (4 bits)