Thank youu lasrchance for the fast reply!
cuurently I'm stuck on how to compare the two array if it has the same value and in the right sequence.
for example,when the program ask for the element that user want to search on the array data, it will store the user number and it will compare with array data to check whether the user entered the number in sequence or not
https://onlinegdb.com/ryHadGEdd
#include <iostream>
using namespace std;
int main()
{
int data[] = {32, 30, 12, 60, 50, 5, 90, 9};
int datasize = sizeof(data);
int key,key1,key2,number,ans=0;
int numdata=datasize/sizeof(int);
cout<<"what two subsequent element do you want to find in the array? : ";
cin>>key1>>key2;
for (int i = 0; i < numdata-1; i++) //need to use numdata-1 because since max index is 7 but in line 94 theres i+1 which leads to element 9 or index 8 and theres no element 9
{
int num = key1;
int num1 = key2;
if (data[i] == num)
{
if (data[i+1] == num1)
{
cout<<"Yes, those number is in the array subsequently"<<endl;
break;
}
else
{
cout<<"Nope, those number is not in the array subsequently"<<endl;
}
}
}
int *pointer = NULL;
cout<<"How Many Elements you want to find? : ";
cin>>number;
pointer = new int[number];
int temp;
for(int j=0; j<number; j++ )
{
cout<<"What are the elements? : "<<j+1<<")";
cin>>temp;
*(pointer+j)= temp;
}
cout<<"the element u have entered are"<<endl;
for(int j=0; j<number; j++ )
{
cout<<*(pointer+j)<<",";
}
delete []pointer;
return 0;
}