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

You are welcome to include more information if you like. This week\'s assignment

ID: 3534718 • Letter: Y

Question

You are welcome to include more information if you like. This week's assignment we will continue our look at user-defined functions, dig deeper into arrays, and introduce pointers. Please have clean and clear indentions. I would highly suggest you take advantage of the started code that I have provided at the end of assignment. Name your file accordingly: LastnameProg12.c.

Functions:
1.
GenerateRandomNumbers: this returns a pseudo-random number that will be used to fill the array. It has been provided.

FillArray: this function fills a two-dimensional array with valid values. It has also been provided.

PrintArray: this function will print a two-dimensional integer array to the screen using standard

array indexes.
4.
PrintArrayByPointer: this function will print a two-dimensional integer array to the screen using pointers to index the array.
5.
FindMaxValue: this function will find the largest value in a two-dimensional integer array. Once the largest value has been discovered, it will dereference the integer pointer that was passed as a parameter, and assign the largest value to it. It will also find the address of the largest value in the array and print it to the screen.
6.
Main: The main function is mostly provided, please provided the missing code.

The program should:

Print the two-dimensional array using indexes.

Print the two-dimensional array using pointers.

Print the address of the largest value in the array as well as the value.

Print the address of variable maxValue as well as its value.

Print the address that PtrInt1 is pointing to as well as its dereferenced value. (PtrInt1 should be

pointing to the address of variable maxValue)

Print the address of arrayInt[0][0] as well as the value it contains.

Print the address that Pt2Int2 is pointing to as well as its dereferenced value. (PtrInt2 should be

pointing to address of arrayInt[0][0]

Explanation / Answer

#include<stdio.h>

#include<stdlib.h>

#include<time.h>

//#include "unistd.h"

#define ROWS 5

#define COLS 5

#define SEED 100

#define CROSSBAR printf("XXXXXXXXXXXXXXXXXX ");

int GenerateRandomNumber()

{

int n;

time_t seconds;

seconds = time(NULL);

//sleep(1);

srand((unsigned int) seconds);

// printf("Seconds: %ld ", seconds);

n=rand() % SEED; /* n is psydo-random number in range of 0 - SEED */

return(n);

}

void FillArray(int multDimensional_Array[][COLS])

{

int i, j;

for(i = 0; i < ROWS; i++){

for(j = 0; j < COLS; j++){

multDimensional_Array[i][j] = GenerateRandomNumber();

}

}

return;

}

void PrintArray(int multDimensional_Array[][COLS])

{

int i, j;

printf(" Print Array By Indexes: ");
for(i = 0; i < ROWS; i++){

for(j = 0; j < COLS; j++){

printf("Print array %d",multDimensional_Array[i][j]);

}
printf(" ");}
return;

}

void PrintArrayByPointer(int *ptrToArray)

{

int i, j;

printf(" Print Array By Pointers: ");
for(i = 0; i < ROWS; i++){

for(j = 0; j < COLS; j++){

printf("%d",*ptrToArray);
ptrToArray++;}
printf(" ");}
return;

}

void FindMaxValue(int multDimensional_Array[ROWS][COLS], int *max)

{

int i, j;
int *PtrToMax = NULL;
printf("Address of highest value in array: %p dereferenced: %d ",PtrToMax, PtrToMax);
return;
}

int main(void) {

int arrayInt[ROWS][COLS]={1,2,3,4,1,2,3,4,1,2,3,4,1,2};

int maxValue;

int *PtrInt1 = NULL; //Set to correct value

int *PtrInt2 = NULL; //Set to correct value

FillArray(arrayInt); //Missing parameter value

PrintArray(arrayInt); //Missing parameter value

PrintArrayByPointer(&arrayInt[0][0]); //Missing parameter value

FindMaxValue(arrayInt, &maxValue); //Missing parameter values


return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote