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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started