Question: This is for C++ I'm having issues with this code i want it to print out the largest number from a undetermined list of double

This is for C++ I'm having issues with this code i want it to print out the largest number from a undetermined list of double numbers which would include negative and positive and decimals and from there display the largest

For the second implementation, your program should first say that the numbers to be entered must be non-negative, and that the user should enter a negative number when all the numbers to be compared are entered. Then the program should read the non-negative numbers of type double, and when a negative number is entered, the program should display the largest of the numbers in the list.

i have this so far

#include using namespace std;

int main() {

int i, n; double arr[0];

cout << "Enter non-negative numbers : "; cin >> n; cout << endl;

for(i = 0; i < n; ++i) { cout << "Enter Number " << i + 1 << " : "; cin >> arr[i]; }

for(i = 1;i < n; ++i) {

if(arr[0] < arr[i]) arr[0] = arr[i]; }

cout << endl << "Largest element = " << arr[0];

return 0; }

please help

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!