Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int input_array(double A[], int n) {
- for(int i = 0; i < n; i++) {
- cout << "Enter element #" << i << ": ";
- cin >> A[i];
- }
- return *A;
- }
- void output_array(double A[], int n) {
- for(int i = 0; i < n; i++)
- cout << A[i] << endl;
- }
- void min(double A[], int n) {
- // Min gets value of 1st element in the array
- int min = A[0];
- for(int i = 0; i < n; i++)
- if(min > A[i] && A[i] < 0)
- min = A[i];
- cout << "Min number is " << min << " and its' index is" << i;
- }
- int main() {
- double A[25];
- int n;
- cout << "Enter array size: ";
- cin >> n;
- // Check if n is smaller than 0 or bigger than 25
- if(n < 0 || n > 25)
- return 0;
- // Inputting array
- input_array(A, n);
- //Minimum negative number
- min(A, n);
- // Output array
- cout << "\n\nArray Output:\n";
- output_array(A, n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement