Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help with this question Please. I have been having problem with trying to

ID: 3557582 • Letter: I

Question

I need help with this question Please. I have been having problem with trying to solve this question. Please if you can help me with it I would really appreciate it. C++ Language

A mathematical set is a collection of non repeating elements. Write a function to test whether an array of arbitrary size containing only digits is a set. The function should return true when the array is a set. You may not use a sort function. Use the following prototype: For example {1, 2, 3} returns true {1, 2, 3} returns false Write, run, and test a program to test the function. The program must also test that the array only contains 0-9.

Explanation / Answer

#include <iostream>
using namespace std;
bool isSet(int Array[],int SIZE);
int main(int argc, char *argv[])
{
int SIZE;
cout<<"Enter Size of Array ";
cin>>SIZE;
int *Array=new int[SIZE];
cout<<"Input Array Element ";
for(int i=0;i<SIZE;i++)
   cin>>Array[i];
if(isSet(Array,SIZE))
   cout<<"Array is Set ";
else
   cout<<"Array is not Set ";
return 0;
}
bool isSet(int Array[],int SIZE){
for(int i=0;i<SIZE;i++){
if(Array[i]>9||Array[i]<0){
   cout<<"Array Contains element not in range[0-9] ";
   break;
   }
}
for(int i=0;i<SIZE;i++)
   for(int j=i+1;j<SIZE;j++)
   if(Array[i]==Array[j])
   return 0;
return 1;
}