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;
}

Commentaires (12)

Connectez-vous pour commenter

Rejoignez la discussion et partagez vos connaissances avec la communauté

JD
Jean Dupont Il y a 2 heures

Excellent tutoriel !

👍 12 Répondre Signaler
CodeurJava ✓ Auteur • Il y a 1 heure

N'hésitez pas si vous avez des questions.