Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
#include #include #include #include qutyio.h / * * Tutorial 0 6 INTRODUCTION: In this week's tutorial you will implement a pseudorandom number generator. This
#include #include #include #include "qutyio.h Tutorial INTRODUCTION: In this week's tutorial you will implement a pseudorandom number generator. This will be of particular relevance to Assessment EX: TASK: Define a global unsigned bit integer called "state". Initialise "state" with a value equal to your student number, where each decimal digit in your student number represents a hexadecimal literal. EXAMPLE: If your student number was n then you should assign the value x to "state". Once you have defined this variable uncomment the first printf statement in the main function. CODE: Write your code for Ex above this line. EX: TASK: Write the function prototype for a function called "next" which takes no parameters and returns no result. CODE: Write your code for Ex above this line. EX: TASK: Write a function called "printrand" which returns no result and takes, as a single argument, a pointer to an unsigned bit integer. The function should inspect the least significant two bits of the integer pointed to by the argument, and depending on the value of the bits, execute one of the following function calls: b: putchar; b: putchar; b: putchar; b: putchar; Once you have written this function uncomment the second printf statement in the main function. CODE: Write your code for Ex above this line. EX: TASK: Complete the implementation for the next function. next should: Right shift the bits in "state" by position. If the bit shifted out of state in step was set take the XOR of "state" with xAEE and store the result in "state". Once you have written this function uncomment the third printf statement in the main function. void nextvoid CODE: Write your code for Ex within this function. int mainvoid serialinit; TODO: Uncomment the line below after Ex is completed. printfEx : state xlX state; TODO: Uncomment the line below after Ex is completed. uintt test b; printfEx : output ; printrand&test; test ; printrand&test; test ; printrand&test; test ; printrand&test; printf ; TODO: Uncomment the line below after Ex is completed. next; printfEx : state xlX state; next; next; next; next; printf state xlX state; EX: The variable "state" together with the next function implement a linearfeedback shift register, which produces a pseudorandom number sequence. This sequence was seeded initialised with your student number. TASK: Write code below to print the next digits derived from this pseudorandom number sequence using next and printrand All digits should be printed on a single line without spaces. NOTE: Call next to advance "state" prior to printing the first digit. TIP: Recall that the unary operator & can be used to get a reference pointer to some data. printfEx : ; CODE: Write your code for Ex below this line. CODE: Write your code for Ex above this line. printf ; END OF TUTORIAL EXERCISES DO NOT EDIT BELOW THIS LINE while ; Loop indefinitely
#include
#include
#include
#include "qutyio.h
Tutorial
INTRODUCTION:
In this week's tutorial you will implement a pseudorandom number
generator. This will be of particular relevance to Assessment
EX:
TASK: Define a global unsigned bit integer called "state".
Initialise "state" with a value equal to your student number, where each
decimal digit in your student number represents a hexadecimal literal.
EXAMPLE: If your student number was n then you should assign the
value x to "state".
Once you have defined this variable uncomment the first printf
statement in the main function.
CODE: Write your code for Ex above this line.
EX:
TASK: Write the function prototype for a function called "next"
which takes no parameters and returns no result.
CODE: Write your code for Ex above this line.
EX:
TASK: Write a function called "printrand" which returns no result
and takes, as a single argument, a pointer to an unsigned bit
integer.
The function should inspect the least significant two bits of the
integer pointed to by the argument, and depending on the value of the
bits, execute one of the following function calls:
b: putchar;
b: putchar;
b: putchar;
b: putchar;
Once you have written this function uncomment the second printf
statement in the main function.
CODE: Write your code for Ex above this line.
EX:
TASK: Complete the implementation for the next function.
next should:
Right shift the bits in "state" by position.
If the bit shifted out of state in step was set take the XOR
of "state" with xAEE and store the result in "state".
Once you have written this function uncomment the third printf
statement in the main function.
void nextvoid
CODE: Write your code for Ex within this function.
int mainvoid
serialinit;
TODO: Uncomment the line below after Ex is completed.
printfEx : state xlX
state;
TODO: Uncomment the line below after Ex is completed.
uintt test b; printfEx : output ; printrand&test; test ; printrand&test; test ; printrand&test; test ; printrand&test; printf
;
TODO: Uncomment the line below after Ex is completed.
next; printfEx : state xlX state; next; next; next; next; printf state xlX
state;
EX:
The variable "state" together with the next function implement a
linearfeedback shift register, which produces a pseudorandom number
sequence.
This sequence was seeded initialised with your student number.
TASK: Write code below to print the next digits derived from this
pseudorandom number sequence using next and printrand
All digits should be printed on a single line without spaces.
NOTE: Call next to advance "state" prior to printing the first
digit.
TIP: Recall that the unary operator & can be used to get a
reference pointer to some data.
printfEx : ;
CODE: Write your code for Ex below this line.
CODE: Write your code for Ex above this line.
printf
;
END OF TUTORIAL EXERCISES
DO NOT EDIT BELOW THIS LINE
while
; Loop indefinitely
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started