Skip to content

EWMW1221/smallest-of-an-array

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

smallest-of-an-array

student information

Name:Eyerus wesene student id:RMNS-4199-/23 course:data structure and algorithm

Algorithm

Input: An array arr of size n. Handle edge case: If the array is empty, return or print an error message. Initialize a variable min to the first element of the array: min = arr[0]. Traverse the array starting from the second element: -For each element arr[i], compare it with min. -If arr[i] < min, update min to arr[i]. After the loop finishes, min contains the smallest number in the array. Output: Return or print min. How to Run the Code Clone the repository to your local machine. Open the terminal and navigate to the repository directory. Compile the C++ code using: Run the compiled program: ./main

how to run the code the problem will output:the smallest number in the array.

  1. Clone the repository to your local machine.
  2. Open the terminal and navigate to the repository directory.
  3. Compile the C++ code using:
    g++ main.cpp -o main 
    

Run the compiled program: ./main Output The program will output: The smallest number in the array is: 2

Contributing Feel free to contribute to this project by forking the repository and submitting a pull request. License This project is licensed under the MIT License.``

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages