Finding the maximum of a painting and its position in C
This program looks for the position of the maximum value in an array in C.#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; } |