| | |
array max min
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2004
Posts: 2
Reputation:
Solved Threads: 0
I need help with my homework assignment. The assignments asks to enter a list of double values with the maxium to be entered is 50. I need to print out the list entered and find the largest and smallest values entered by the user. This is what I have but I'am getting an unexpected end of file error when I compile my program.
#include <iostream>
#include <cmath>
const int max=50
void readlist(double a[], int s)
void display(double a[], int s)
double largest(double a[], int s)
double lowest(double a[], int s)
int main()
{
using namespace std;
double list [max]
cout<<"Please enter a list size"<<endl;
cin>>list;
if(max>50)
{
cout<<"The size you have entered is too large."<<endl;
cout<<"The maximum size is 50."<<endl;
cout<<"Please re-enter a list size"<<endl;
return 0;
}
void display(double a[], int s)
{
for (i=0;i<size;i++)
cout<<"Please enter some double values "<<endl;
cin>>a[i];
cout<<"The list you have entered is"<<endl;
cin>>list[i];
cout<<list[i]<<" ";
if(i==5)cout<<"endl";
}
double largest(double a[], int s)
double lowest(double a[], int s)
for (i=0;i<size;i++)
if(largest<list[i])
largest=list[i];
{
cout<<"The largest value is:"<<endl;
cin>>largest;
return largest;
}
else if (lowest>list[i])
lowest=list[i];
}
cout<<"The smallest value is:"<<endl;
cin>>lowest;
return lowest;
}
#include <iostream>
#include <cmath>
const int max=50
void readlist(double a[], int s)
void display(double a[], int s)
double largest(double a[], int s)
double lowest(double a[], int s)
int main()
{
using namespace std;
double list [max]
cout<<"Please enter a list size"<<endl;
cin>>list;
if(max>50)
{
cout<<"The size you have entered is too large."<<endl;
cout<<"The maximum size is 50."<<endl;
cout<<"Please re-enter a list size"<<endl;
return 0;
}
void display(double a[], int s)
{
for (i=0;i<size;i++)
cout<<"Please enter some double values "<<endl;
cin>>a[i];
cout<<"The list you have entered is"<<endl;
cin>>list[i];
cout<<list[i]<<" ";
if(i==5)cout<<"endl";
}
double largest(double a[], int s)
double lowest(double a[], int s)
for (i=0;i<size;i++)
if(largest<list[i])
largest=list[i];
{
cout<<"The largest value is:"<<endl;
cin>>largest;
return largest;
}
else if (lowest>list[i])
lowest=list[i];
}
cout<<"The smallest value is:"<<endl;
cin>>lowest;
return lowest;
}
![]() |
Similar Threads
- What code to find MAX and MIN? [Problem] (Java)
- Average/max/min (C)
- Max and Min of more than 2 numbers (Java)
- extract max-min value from every column in array (C)
- arrange values from row of database in php from max to min, from min to max and value (PHP)
- max and min (C++)
Other Threads in the C++ Forum
- Previous Thread: Using map<> with classes
- Next Thread: Hot!! Right off the press
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count data database delete deploy developer dll download dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings struct temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





