How to change my code

Hi everyone, I’m quite green in programming but I want to know how to change my code that generates ARRAY and divides every element by RAND_MAX number into code that generates MATRIX and divides every element by RAND_MAX number. I might imagine the whole algorithm but I don’t know for sure how exactly do it.
Here’s the code:

#include <stdio.h>
using namespace std;
global void division(float *vector, int maxi, float *result_vector) {

result_vector[blockIdx.x] = vector[blockIdx.x] / maxi;


int main(void) {
int blocks_count=4;
float *vector, result_vector;
int size = blocks_count
int max = RAND_MAX;
cout<<"Number: “<<” Max: “<<” Number/Max: “<<endl;
vector = (float *)malloc(size);
result_vector=(float *)malloc(size);
for (int i=0; i<5; i++){
vector[i] = rand();
cout<<vector[i]<<” “<<max<<” "<<vector[i]/max<<endl;

float *gpu_vector;
float *gpu_result_vector;

cudaMalloc((void **)&gpu_vector, size); //Paskiriame vietos grafinÄ—s plokÅtÄ—s atmintyje
cudaMalloc((void **)&gpu_result_vector, size);

cudaMemcpy(gpu_vector, vector, size, cudaMemcpyHostToDevice);
cudaMemcpy(result_vector, gpu_result_vector, size, cudaMemcpyDeviceToHost);
cout<<"Result vector: “;
for (int i=0; i<5; i++)
cout<<result_vector[i]<<” ";

free(vector); free(result_vector);
cudaFree(gpu_vector); cudaFree(gpu_result_vector);
return 0;

To change your code, open your source file in a text editor, modify it as needed, and save it. Hope that helps.