codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include<iostream> #include<iomanip> #include<string> #include<fstream> using namespace std; int highest(int [], int); int lowest(int[], int); double average(int[],int); int main() { const int SIZE=20; int grades[SIZE]; for (int x=0; x<20; x++) { grades[x]=x*x; } cout<<"The highest grade is: "<<highest(grades, SIZE)<<endl; cout<<"The lowest grade is: "<<lowest(grades, SIZE)<<endl; cout<<"The average grade is: "<<average(grades, SIZE)<<endl; return 0; } int lowest(int grades[],int SIZE) { int lowest=grades[0]; for(int count=1; count<SIZE; count++) { if(grades[count]<lowest) lowest=grades[count]; } return lowest; } int highest(int grades[],int SIZE) { int highest=grades[0]; for(int count=1; count<SIZE; count++) { if(grades[count]>highest) highest=grades[count]; } return highest; } double average(int grades[],int SIZE) { double average=0.0; int total(0); for(int count=0;count<SIZE; count++) { total+=grades[count]; } average=total/20; return average; }
Private
[
?
]
Run code
Submit