Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help getting error message on putty read below //I am running this on visual studio and its running perfectly fine. //WHen i try to

Please help getting error message on putty read below //I am running this on visual studio and its running perfectly fine. //WHen i try to run it on putty, im getting an error message for //the max and min //saying : INT_MAX and INT_MIN were not declared in this scope //Please help ! #include  #include  // To use ifstream #define ARRAY_SIZE 10 using namespace std; void readData(int numbers[]) { ifstream inputFile; // Input file stream object // Open the file. inputFile.open("arrays.txt"); int index = 0; // Read the numbers from the file into the array. while (inputFile >> numbers[index] && index < 10) { index++; } // Close the file. inputFile.close(); } void printArray(int numbers[]) { for (int i = 0; i < ARRAY_SIZE; i++) { cout << numbers[i] << " "; } cout << endl; } void reverseArray(int numbers[]) { for (int i = ARRAY_SIZE - 1; i >= 0; i--) { cout << numbers[i] << " "; } cout << endl; } void minMax(int numbers[]) { int minNumber = INT_MAX; int maxNumber = INT_MIN; //return the minimum and the maximum for (int i = 0; i < ARRAY_SIZE; i++) { if (numbers[i] > maxNumber) { maxNumber = numbers[i]; } if (numbers[i] < minNumber) { minNumber = numbers[i]; } } cout << "Maximum number = " << maxNumber << endl; cout << "Minimum number = " << minNumber << endl; } int main() { int numbers[ARRAY_SIZE]; // Array number with 10 elements readData(numbers); // Display the numbers read: cout << "The numbers in the array are the following: " << endl; printArray(numbers); //display the reverse order cout << "The array in reverse order looks like the following: " << endl; reverseArray(numbers); // Display the numbers read: cout << "The numbers in the array are the following: " << endl; printArray(numbers); minMax(numbers); getchar(); return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Managing Your Information How To Design And Create A Textual Database On Your Microcomputer

Authors: Tenopir, Carol, Lundeen, Gerald

1st Edition

1555700233, 9781555700232

More Books

Students also viewed these Databases questions

Question

Why are marketing analytics so important in the age of big data?

Answered: 1 week ago