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

I need to write a simple random number generator that inserts at the head(linked

ID: 640555 • Letter: I

Question

I need to write a simple random number generator that inserts at the head(linked list) using more than one function. (please show output). I alread wrote some of it.

#include <iostream>

#include <cstdlib>

#include <ctime>

#include <fstream>

using namespace std;

struct nodetype

{

int num;

nodetype *next;

};

ifstream infile;

int main()

{

int digit;

nodetype *head = NULL;

nodetype *ptr;

nodetype *r;

ptr = new nodetype;

r = new nodetype;

while (!infile.eof())

{

infile >> digit;

if (head == NULL)

{

head = new nodetype;

head->num = digit;

head->next = NULL;

ptr = head;

}

else

{

r = new nodetype;

r->num = digit;

r->next = NULL;

ptr->next = r;

ptr = r;

}

}

void random();

}

void random()

{

srand(5000);

for (int count = 0; count < 20; count++)

{

cout << rand() << " ";

if ((count + 1) % 5 == 0)

cout << endl;

}

}

Explanation / Answer

private static void RandomNum() { //Initialize an array int[] randomList = new int[1000]; //Initialize an instance of random class Random rnd = new Random(); // integer variable int counter = 0; //Error handler try { while (counter < 1000) { //store random num int random = rnd.Next(1, 1001); if (Array.IndexOf(randomList, random)