answersLogoWhite

0

#include <iostream>

using std::cout;

using std::cin;

using std::endl;

void input(double arr[], const int arr_size);

double max(double arr[], const int arr_size);

int main()

{

const int arr_size = 5;

double arr[arr_size] = {0.0};

input(arr, arr_size);

cout << "Highest number is: " << max(arr, arr_size) << endl;

system("PAUSE");

return 0;

}

void input(double arr[], const int arr_size)

{

cout << "Enter " << arr_size << " elements to find the highest:" << endl;

for (int i = 0; i < arr_size; i++)

{

cout << (i + 1) << " element is: ";

cin >> arr[i];

}

}

double max(double arr[], const int arr_size)

{

double highest_num = arr[0];

for (int i = 0; i < arr_size; i++)

{

if (highest_num < arr[i])

{

highest_num = arr[i];

}

}

return highest_num;

}

User Avatar

Wiki User

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

CoachCoach
Success isn't just about winning—it's about vision, patience, and playing the long game.
Chat with Coach
ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi
BeauBeau
You're doing better than you think!
Chat with Beau

Add your answer:

Earn +20 pts
Q: How do you print highest number in an array in C language?
Write your answer...
Submit
Still have questions?
magnify glass
imp