Having trouble with arrays/ functions

Trying to use an array and find perfect numbers in it. I have code I wrote using input value but I have no idea where to start to use an array. Array should be 8000 in size, I will update as I go along as well. Any tips would be amazing

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  

#include <iostream>
#include <cmath>
using namespace std;
void showPerfect(int, int, int);
void isPerfect(int);
int main ()
{
    int num;
    cout << "Enter a number to find if it is perfect!";
    cin >> num;
    isPerfect(num);


return 0;
}

void isPerfect(int value1)
{
    int sum=0, i;
    for (i=1; i<=(value1/2);i++)
    {
        if(value1 % i==0)
        {
            sum = sum + i;
        }

    }
    showPerfect(sum, i, value1);
}

void showPerfect(int num1, int num2, int num3)
{
    if (num1 == num3)
    {
        cout << num1 << " Is perfect";
    }
    else
    {
        cout << num1 << " Is not perfect";
    }
}
What should be store in this array?

Generally an array looks like this:

1
2
3
int a[8000] = {0}; //  = {0} sets the whole array to 0

a[0] = 1; // This sets the first element to 1 


Note that an index within an array starts with 0. Hence indexes 0...7999 are valid.

Topic archived. No new replies allowed.