Write a program to find the minimum number in integer array

 

Write a program to find the minimum number in integer array

 

  1. #include <iostream>
    using namespace std;
       
    int main(){
        int input[100], count, i, min;
           
        cout << "Enter Number of Elements in Array\n";
        cin >> count;
         
        cout << "Enter " << count << " numbers \n";
          
        // Read array elements
        for(i = 0; i < count; i++){
            cin >> input[i];
        }
         
        min = input[0];
        // search num in inputArray from index 0 to elementCount-1 
        for(i = 0; i < count; i++){
            if(input[i] < min){
                min = input[i];
            }
        }
     
        cout  << "Minimum Element\n" << min;
     
        return 0;
    }

    المخرجات

    Enter Number of Elements in Array
    6
    Enter 6 numbers
    8 4 7 1 3 9
    Minimum Element
    1

     

     

    • 0
أضف اجابة

أضف اجابة

‫تصفح