Objectifs

  1. A quoi sert un tableau ?
  2. Comment déclarer un tableau ?
  3. Comment initialiser un tableau ?
  4. Comment remplir un tableau ?
  5. Les erreurs à éviter

Comment déclarer un tableau ?

const int Taille=5;

int Tab1D[Taille];

Comment initialiser un tableau ?

int Tab1D[5]      ={1,2,3,4,5};

int Tab1D[Taille] ={1,2,3,4,5};

int Tab1D[6]      ={1,2,3,4,5,6};

int Tab1D[]       ={1,2,3,4,5,6};

Comment remplir un tableau (ou initialiser) ?

 




int Tab1D[Taille];

for (int i=0;i<Taille; i++)

  Tab1D[i]=i;

Les erreurs à éviter

  1. Dépassement de la taille du tableau
Ex: for (int i=0;i<=Taille; i++) Tab1D[i]=i;
  1. Mauvais choix de l’indice
Ex: for (int i=1;i<=Taille; i++) Tab1D[i]=i;
Click to rate this post!
[Total: 0 Average: 0]

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Retour en haut

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

FPGA | Arduino | Matlab | Cours will use the information you provide on this form to be in touch with you and to provide updates and marketing.