Question: C++ please help having troubles with separating code into .h file and .ccp file below is the response I got when I turned in the

C++ please help having troubles with separating code into .h file and .ccp file

below is the response I got when I turned in the code

"You are defining functions in main, your header file should only have function declarations, not code

#include #include #include #include using namespace std; int getSize() { int n; cout << "Please enter number between 10 and 20"; cin >> n; if (n >= 10 && n <= 20) return n; else { cout << "Number is not between 10 and 20 "; return 20; } } int* createArray(int size) { int *array = new int[size]; srand(time(0)); for (int i = 0; i < size; ++i) *(array+i) = (rand() % 99)+1; return array; } void sortArray(int *array, int size) { sort(array, array+size); } void displayArray(const int *array, int size) { for (int i = 0; i < size; ++i) { cout << *(array+i) << ", "; if((i+1)%5 == 0) cout << endl; } cout << endl; } int getInteger() { int value; cout << "Enter Number to search in the array: "; cin >> value; return value; } bool search(const int *array, int size, int value) { for (int i = 0; i < size; ++i) if(value == *(array+i)) return true; return false; } int main() { int size = getSize(); int *array = createArray(size); sortArray(array, size); displayArray(array, size); int value = getInteger(); bool found = search(array, size, value); if( found ) cout << "Number is in the array. "; else cout << "Number isn't in the array. "; return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!