Search
 
SCRIPT & CODE EXAMPLE
 

C

how to get the lowest number on a array in c

int main (void)
{
int temp, size;
//setting the array
      int array[] = {10, 20, 25, 63, 96, 57};
      size = array.length;
/*user input array
	int array[];
    for (int i = 0; i < 5; ++i) 
    {
        cin >> array[i];
    }
*/
      for(int i = 0; i<size; i++ )
      {
         for(int j = i+1; j<size; j++)
         {
            if(array[i]>array[j])
            {
//making a temp array
               temp = array[i];
//passing the array
               array[i] = array[j];

               array[j] = temp;
            }
         }
      }
//printing the lowest array which is located at array[0]  
    System.out.println("Smallest element of the array is:: "+array[0]);
//printing the highest array is located at the last value of the array -1
	System.out.println("Smallest element of the array is:: "+array[size - 1]);
}
Comment

PREVIOUS NEXT
Code Example
C :: check whether a number is prime or not in c 
C :: lichess puzzles 
C :: how to get file size in c 
C :: millis() 
C :: declare string in c 
C :: sh: tailwindcss: command not found 
C :: class in oops 
C :: print an int c 
C :: Complete the function in the editor. It has one parameter: an array, . It must iterate through the array performing one of the following actions on each element: 
C :: 2d array in c 
C :: chevront de vlavier 
C :: how to free memory in c 
C :: division en java 
C :: c add char to char array 
C :: define constant c 
C :: C special character display 
C :: c program for assignment operator 
C :: C Syntax of goto Statement 
C :: Symmetrical matrix in C 
C :: voide means in c 
C :: spacemacs start server 
C :: Minimum Distance between words[AMAZON] 
C :: can torch light bring change in chemical reaction 
C :: nested if example in c 
C :: input multipal data types 
C :: how to alias an awk command 
C :: how to compress a file in c 
C :: cum creez un nou nod how to create a new node 
C :: [4,5,6] 
C :: C programming statician 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =