I need to find the minimum value in int array, but the answer it gives me is really odd and from that I cannot even judge where the error is, I would really appreciate help. Here is the code I have written:
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <conio.h>
#include <random>
#include <cstdlib>
#include <ctime>
using namespace std;
int minVert(int minimum, int i) {
int j, array[20];
for (j = 0; j < 19; j++) {
if (array[i] < minimum ) {
minimum = array[i];
}
}
return minimum;
}
int main(int k, int minimum) {
int array[20];
srand(time(NULL));
for (int i = 0; i < 20; i++) {
k = rand() % 1000 + 2;
array[i] = k;
}
cout << "Tiek generets masivs..." << endl << "..." << endl << "..." << endl << "..." << endl << endl;
cout << "Masiva elementi ir: " << endl;
for (int j = 0; j <20; j++) {
cout << array[j] << endl;
}
cout << endl << "Masiva mazaka vertiba ir: " << endl << minimum << endl << endl;
cout << "Nospiediet jebkuru taustinu, lai izietu no programmas" << endl;
_getch();
return 0;
}