How can i possibly use array to create a password program?

#include <iostream>
using namespace std;

main()
{

 int password[5] = {1,2,3,4,5};
        int pass[5];

        cout << "enter pass: ";
        cin >> pass[5];

        if(pass[5] == password[5])
        {
        cout <<"hey";
        }
        else
        {
        cout << "error";
        }
}

first off, a few things :
are you really using number as password ? if yes then consider following things :-

An Array Arr[5] will consist 5 values from 0 to 4 index hence there will be nothing in Arr[5]. ok.

cout << "enter pass: ";
cin >> pass[5];

by doing so , you are getting value at the fifth index of pass array which is not valid(because we can access elements from 0 to size-1 values) .However the statement will not throw any error but i don't think its valid. if you want to create a program to check password then i think this can be achieved without using Array. Look at this :-

int x,y;
x=12345;
cin>>y;
if(x==y)
cout<<"Password is valid";
else
cout<<"Password incorrect";

also consider other data types as your requirments(if you need password around 10 character long) then use of string or array.