Finding the position of the minimum number in a table in C
This program looks up the minimum of an array and its position.#include< stdio.h> #include< stdlib.h> int main() { int min,position, length=10; int tab[10]={1,2,3,4,5,6,7,8,9,10}; min=999999; for (int i=0; i< length; i++) { if(tab[i]< min){ min=tab[i]; position=i; } } printf("Minimum : %d\nPosition: %d\n",min,position); return 0; } |