Name: Anonymous 2007-12-12 7:18
Hi /prog/, I've got a problem with the program I just wrote, when I try to complie it, it says "invalid conversion form 'int' to 'int*'". Could you help me solve this please? Here's the code:
#include <stdio.h>
#include <math.h>
#include <conio.h>
void remplir(int tab[5], int i)
{
for(i=0; i<=4; i++)
{
scanf("%d",&tab[i]);
}
}
void afficher(int tab[5], int i)
{
for(i=0; i<=4; i++)
{
printf("%d",tab[i]);
}
}
int sommme(int somme, int tab[5], int i)
{
somme=0;
for(i=0; i<=4; i++)
{
somme=somme+tab[i];
}
}
void tri(int tab[5], int b, int i, int j)
{
for(i=0; i<=4; i++)
{
for(j=0; j<=4; j++)
{
if(tab[i]<tab[j])
{
b=tab[i];
tab[i]=tab[j];
tab[j]=b;
}
}
}
}
main()
{
int tab[5];
int i,j,k,somme,rep,b;
do
{
printf("1.Remplir le tableau\n2.Afficher le tableau\n3.Afficher la somme des cases du tableau\n4.Afficher le tableau trié par ordre décroissant\n0.Quitter\nVotre choix:");
scanf("%d",&rep);
switch(rep)
{
case 1:remplir(tab[5],i);break;
case 2:afficher(tab[5],i);break;
case 3:sommme(somme,tab[5],i);break;
case 4:tri(tab[5],b,i,j);break;
default: printf("Votre choix n'est pas valide");break;
}
while(rep!=0);
}
getch();
}
Thank you in advance.
#include <stdio.h>
#include <math.h>
#include <conio.h>
void remplir(int tab[5], int i)
{
for(i=0; i<=4; i++)
{
scanf("%d",&tab[i]);
}
}
void afficher(int tab[5], int i)
{
for(i=0; i<=4; i++)
{
printf("%d",tab[i]);
}
}
int sommme(int somme, int tab[5], int i)
{
somme=0;
for(i=0; i<=4; i++)
{
somme=somme+tab[i];
}
}
void tri(int tab[5], int b, int i, int j)
{
for(i=0; i<=4; i++)
{
for(j=0; j<=4; j++)
{
if(tab[i]<tab[j])
{
b=tab[i];
tab[i]=tab[j];
tab[j]=b;
}
}
}
}
main()
{
int tab[5];
int i,j,k,somme,rep,b;
do
{
printf("1.Remplir le tableau\n2.Afficher le tableau\n3.Afficher la somme des cases du tableau\n4.Afficher le tableau trié par ordre décroissant\n0.Quitter\nVotre choix:");
scanf("%d",&rep);
switch(rep)
{
case 1:remplir(tab[5],i);break;
case 2:afficher(tab[5],i);break;
case 3:sommme(somme,tab[5],i);break;
case 4:tri(tab[5],b,i,j);break;
default: printf("Votre choix n'est pas valide");break;
}
while(rep!=0);
}
getch();
}
Thank you in advance.