Run ❯
Get your
own
website
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
Python
C
Java
my_array = [7, 12, 9, 4, 11] minVal = my_array[0] for i in my_array: if i < minVal: minVal = i print('Lowest value:',minVal) #Python
#include
int main() { int my_array[] = {7, 12, 9, 4, 11}; int size = sizeof(my_array) / sizeof(my_array[0]); int minVal = my_array[0]; for(int i = 0; i < size; i++) { if(my_array[i] < minVal) { minVal = my_array[i]; } } printf("Lowest value: %d\n", minVal); return 0; } //C
public class Main { public static void main(String[] args) { int[] my_array = {7, 12, 9, 4, 11}; int minVal = my_array[0]; for (int i : my_array) { if (i < minVal) { minVal = i; } } System.out.println("Lowest value: " + minVal); } } //Java
Python result:
C result:
Java result:
Lowest value: 4
Lowest value: 4
Lowest value: 4