Question: NASM code must: 1 . Read number as input as the number of elements in array using the C function scanf ( ) . If

NASM code must:
1. Read number as input as the number of elements in array using the C function
scanf(). If the number less than or equal to 0, you must use 10 as the array size.
2. Read seed as input to use as the seed to the C function rand(), using the C function
scanf(). If the number 0(zero) is given as input, then you must use 3 as the seed
value.
a. Seed the rand() with the given seed value. Check man 3 rand.
3. Read a value to apply to rand() values as a modulo value ( like the C operator %). If
the number is less than or equal to 0 given as input, you must use the value 100 as the
modulo value.
4. Allocate an array of 4-byte values, based on array size (from step 1) using the C
function malloc().
5. Loop through array and assign random numbers into array, modulo the input value
(from step 3). C pseudo-code for this might look like:
int *array; //4-bytes per index
array = malloc(array_size *);
for(int i =0; i < array_size; i++){
array[i]= rand()% mod_value;
}
6. Loop through the array from index 0 to index (array_size 1) and print the
value from each index. This must be a separate loop from step 5.
7. No memory leaks.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!