Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

If you want to generate random number alike throwing a dice. Which sentence of t

ID: 3795769 • Letter: I

Question

If you want to generate random number alike throwing a dice. Which sentence of this program should be modified? What will be the value of new sentence?

#include <stdint.h> // preprocessor directive to include file

uint8_t random(void); // function declaration

uint32_t M = 1; // global variable

int main(void) {   // main function

       uint8_t x;

       x = random(); // function call

       return 0;

}

uint8_t random(){ // function defination

       uint8_t result;

       M = 1664525*M + 1013904223;

       result = 1 + ((uint8_t) M % 256);

       return result;

}

Explanation / Answer

int main(void) {   // main function

       uint8_t x;

       x = random();

       return 0;

}

uint8_t random(){ // function defination

       uint8_t result;

       M = 1664525*M + 1013904223;

       result = 1 + ((uint8_t) M % 6);//modified sentence.. %5 will generate remainders 0,1,2,3,4,5 adding them 1, will //make 1,2,3,4,5,6... which is outcome of dice

       return result;

}