This program searches for the position of the maximum value in a C language.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include<stdio.h> #include<stdlib.h> int main() { int max,position, length=10; int tab[10]={1,2,3,4,5,6,7,8,9,10}; max=0; for (int i=0 ; i< length ; i++) { if(tab[i]>max){ max=tab[i]; position=i; } } printf("Maximum : %d\nPosition : %d\n",max,position); return 0; } |