#include <iostream>
#include <stdlib.h>
#include <time.h>
usingnamespace std;
// Use a constant for the size of the array.
constint SIZE = 3;
int v[SIZE];
// Note that the names of the function parameters in the definition are
// not the same as the arguments when you actually call it. In the definition
// the parameters must be individual variable names, not array elements.
int
gcd(int a, int b)
{
int r;
// Note that you need braces for multiple statements in the while loop
// also note that the logic here is slightly different from your code.
while (b != 0) {
r = b;
b = a % b;
a = r;
}
return a;
}
int
main()
{
int i;
// seed the random number generator. Otherwise you get the same values
// each time.
srand(time(0));
// arrays start at index 0
for (i = 0; i < SIZE; i++) {
v[i] = rand() % 20000 + 1;
cout << v[i] << " ";
}
cout << '\n'; // print a newline so you can tell where the gcd() is
cout << gcd(v[1], v[2]) << '\n';
return 0;
}