Click here to Skip to main content
15,617,231 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


typedef int vect [30];

//Prototypes*//
void aff_tableaux (vect LOL, int n); //void car elle ne retourne rien
int somme (vect LOL, int n);
float ecart_type (vect LOL, int n);
float val_minimale (vect LOL, int n);
float val_maximale (vect LOL, int n);

//***************************************************************************//

//fonctions//

void aff_tableaux (vect LOL, int n);
{
{     
    int i;
    
    printf("Les elements du tableaux sont:\n");  
    for (i =0; i<n; i++)
        printf("%d\n", LOL[i]);
    
}
int somme(vect LOL, int n)
    {
        int i;
    int s = 0;
    for (i = 0; i<n; i++)
        {
        s = s + LOL[i];
        //printf ("LOL = %d\n", LOL {i]);
        }
    //printf("Somme s = %d \n", s);
    
    return s;
    }
float moyenne (vect LOL, int n)
    {
        float m = 0;
        m = (somme(LOL, n)/n);
        printf ("Moyenne m =%f \n", m);
        
        return m;
    }
float ecart_type (vect LOL, int n)
        {
            int i;
            float e_t;
            e_t = sqrt(((LOL[i]-moyenne(LOL, n)) *(LOL[i] - moyenne(LOL,n)))/n);
            printf ("Ecart-type e_t =%f \n", e_c);
            
            return e_c;
        }

int valeur_minimale (vect LOL, int n)
    {
            int val_min;
            int i;
            
            for (i+0; i<n; i++)
            {
                if(LOL[i]<val_min)
                    val_min = LOL[i];
            }
            printf ("La valeur minimale est de =%d \n", val_min);
            
            return val_min;
    }
int valeur_maximale (vect LOL, int n)
    {
            int val_max;
            int i;
            
            for (i+0; i<n; i++)
            {
                if(LOL[i]>val_max)
                    val_max = LOL[i];
            }
            printf ("La valeur maximale est de =%d \n", val_max);
            
            return val_max;
    }
    
    //****************************************//
    int main (void);
    {
    int N, i;
    vect B;
    
    printf("Veuillez entrer le nombre d'entier N à saisir: \n");
    scanf("%d", &N);
    printf("N =% d \n", N);
    
    while (N>30) // Si l'utilisateur demande plus de 30 valeurs, recommencer la saisie
    {
        printf("Veuillez entrez le nombre d'entiers N a saisir: \n");
        scanf("%d", &N);
        printf ("N = %d \n", n);
    }
    for (i = 0; i<N; i++)
    {
        printf("Saisissez les valeurs a entrer dans le tableau\n");
        scanf("%d", &B[i]);
    }
    aff_tableaux (B,N);
    somme(B, N);
    moyenne(B,N);
    ecart_type(B,N);
    val_minimale(B,N);
    val_maximale(B,N);
    
    return 0;
    
}
}


What I have tried:

I try too change the { at the beginning and at the end but the program still not work help me please thanks you.
Posted
Updated 22-Sep-21 20:43pm

Look at your code:
C
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


typedef int vect [30];

//Prototypes*//
void aff_tableaux (vect LOL, int n); //void car elle ne retourne rien
int somme (vect LOL, int n);
float ecart_type (vect LOL, int n);
float val_minimale (vect LOL, int n);
float val_maximale (vect LOL, int n);

//***************************************************************************//

//fonctions//

void aff_tableaux (vect LOL, int n);
{
{     
    int i;
You have a function prototype for aff_tableaux then you follow it with a second prototype for the same function, and two odd looking open curly brackets.
Probably, you didn't want one of the open curlies, and you don't want the semicolon:
C
void aff_tableaux (vect LOL, int n)
{     
    int i;
That should start to get rid of your errors - but do look closely at your code when you get syntax errors, as it's a lot quicker to fix them yourself than wait for others to do it for you! :laugh:
 
Share this answer
 
Comments
CPallini 23-Sep-21 2:13am    
5.
on top of what 'Griff said, you also have a semicolon where it doesn't belong. It needs to be removed:
C
int main (void);
 
Share this answer
 
Comments
CPallini 23-Sep-21 2:13am    
5.
I tried to fix the (numerous) bugs of your code. The result is below.
C
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


typedef int vect [30];

//Prototypes*//
void aff_tableaux (vect LOL, int n); //void car elle ne retourne rien
int somme (vect LOL, int n);
double moyenne (vect LOL, int n);
void ecart_type (vect LOL, int n);
int valeur_minimale (vect LOL, int n);
int valeur_maximale (vect LOL, int n);

//***************************************************************************//


int main ()
{
  int N, i;
  vect B;

  do
  {
    printf("Veuillez entrez le nombre d'entiers N a saisir: \n");
    scanf("%d", &N);
    printf ("N = %d \n", N);
  } while (N>30); // Si l'utilisateur demande plus de 30 valeurs, recommencer la saisie


  for (i = 0; i<N; i++)
  {
    printf("Saisissez les valeurs a entrer dans le tableau\n");
    scanf("%d", &B[i]);
  }

  aff_tableaux(B,N);
  printf("Somme s = %d \n", somme(B, N));
  printf ("Moyenne m =%f \n", moyenne(B, N));
  ecart_type(B, N);
  printf ("La valeur minimale est de =%d \n", valeur_minimale(B, N));
  printf ("La valeur maximale est de =%d \n", valeur_maximale(B, N));

  return 0;

}

//fonctions//

void aff_tableaux (vect LOL, int n)
{
  int i;

  printf("Les elements du tableaux sont:\n");
  for (i =0; i<n; i++)
    printf("%d\n", LOL[i]);

}

int somme(vect LOL, int n)
{
  int i;
  int s = 0;
  for (i = 0; i<n; i++)
  {
    s = s + LOL[i];
  }

  return s;
}

double moyenne (vect LOL, int n)
{
  double m = somme(LOL, n)/((double)n);

  return m;
}

void ecart_type (vect LOL, int n)
{
  int i;
  double m = moyenne(LOL, n);

  for (i = 0; i<n; ++i)
  {
    double e_t = m - LOL[i];
    if (e_t < 0) e_t = -e_t;
    printf ("Ecart-type e_t[%d] =%f \n", i, e_t);
  }

}

int valeur_minimale (vect LOL, int n)
{
  int val_min = LOL[0]; // TODO: handle the n==0 corner-case
  int i;

  for (i=1; i<n; i++)
  {
    if( LOL[i] < val_min)
    {
      val_min = LOL[i];
    }
  }
  return val_min;
}

int valeur_maximale (vect LOL, int n)
{
   int val_max = LOL[0]; // TODO: handle the n==0 corner-case
   int i;

   for (i=0; i<n; i++)
   {
     if(LOL[i]>val_max)
     {
       val_max = LOL[i];
     }
  }
  return val_max;
}
 
Share this answer
 
Comments
Patrice T 23-Sep-21 3:23am    
+5
CPallini 23-Sep-21 3:56am    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900