im having a difficult time figuring out my last two functions.
first one which is the
int divelement(int a[], int size);
this function is suppose to find and print the elements of my array that are only divisible by 5, so the answer will be like 10,15,90, and 95. i need help figuring out the algorithm
for my second one
int search(int a[], int size);
the user enters a number, and if the number is in the array it outputs "the number you enter does exist" and if it doesnt it outputs "the number you enter does not exist"
any help will be appreciated. or at least anyway how to get this started. thanks
#include <iostream>
#include <cmath>
using namespace std;
void printArray(int a[], int size);
void reverse(int a[], int size);
int average(int a[], int size);
int min( int a[], int size);
int divelement(int a[], int size);
int search(int a[], int size);
int main()
{
const int size = 10;
int small,a[] = {10, 15, 27, 89, 90, 95, 27, 13, 99, 33};
small = a[0];
int number;
cout << "The original array is: ";
printArray(a,10);
cout << endl;
reverse(a,size);
cout << "The reversed array is: ";
printArray(a,size);
cout << endl;
cout << "The average of the array is: "
<< average(a, size) << endl;
min(a, size);
cout << "The smallest element in the array is: "
<< small << endl;
cout << "Enter a number between 1 and 99: " << endl;
cin >> number;
if(number == true)
cout << "The number you entered exists";
else
cout << "The number your entered does not exist in the array"
<< endl;
return 0;
}
void printArray(int a[], int size)
{
for (int i = 0; i < size; i++)
cout << a[i] << " ";
}
void reverse(int a[],int size)
{
int temp=0;
for(int i=0;i<=(size)/2;i++)
{
temp=a[i];
a[i]=a[size-i-1];
a[size-i-1]=temp;
}
}
int average(int a[], int size)
{
int sum = 0;
for (int i = 0; i < size; i++)
sum += a[i
return (sum / size);
}
int min(int a[], int size)
{
int i;
int small;
for (i = 1; i < size; i++)
{
if(small > a[i])
small = a[i];
}
return small;
}
int divelement(int a[], int size)
{
}
int search(int a[], int size[]
{
}