Programme qui ne marche pas
quent511
-
fiddy Messages postés 441 Date d'inscription Statut Contributeur Dernière intervention -
fiddy Messages postés 441 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour,
Est ce que quelqu'un pourrait m'aider mon prof m'a donner un programme en C à debugger et je n'y arrive pas. Pouvez vous m'aider merci.
Je vous donne le programme du prof:
#include (stdio.h)
#include <lib.h>
int main()
{
int tailleTab1 = 2;
int tab1[2] = {1, 2};
int tailleTab2 = 3;
int tab2[3] = {3, 4, 5};
/* Calcul du somProd
int i, j
i = 0;
j = 0;
while i < tailleTab1)
{
while (j < tailleTab2)
somProd = somProd + tab1[i] * tab2[j];
}
}
printf("%f\m, somProd);
return 0;
}
Et voici le mien:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int tailleTab1 = 2;
int tab1[2] = {1, 2};
int tailleTab2 = 3;
int tab2[3] = {3, 4, 5};
int somProd;
int i, j;
i = 0;
j = 0;
while (i < tailleTab1)
{
while (j < tailleTab2)
somProd = somProd + tab1[i] * tab2[j];
}
printf ("%f\m somProd");
return 0;
}
Dites moi ce qui cloche.
Est ce que quelqu'un pourrait m'aider mon prof m'a donner un programme en C à debugger et je n'y arrive pas. Pouvez vous m'aider merci.
Je vous donne le programme du prof:
#include (stdio.h)
#include <lib.h>
int main()
{
int tailleTab1 = 2;
int tab1[2] = {1, 2};
int tailleTab2 = 3;
int tab2[3] = {3, 4, 5};
/* Calcul du somProd
int i, j
i = 0;
j = 0;
while i < tailleTab1)
{
while (j < tailleTab2)
somProd = somProd + tab1[i] * tab2[j];
}
}
printf("%f\m, somProd);
return 0;
}
Et voici le mien:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int tailleTab1 = 2;
int tab1[2] = {1, 2};
int tailleTab2 = 3;
int tab2[3] = {3, 4, 5};
int somProd;
int i, j;
i = 0;
j = 0;
while (i < tailleTab1)
{
while (j < tailleTab2)
somProd = somProd + tab1[i] * tab2[j];
}
printf ("%f\m somProd");
return 0;
}
Dites moi ce qui cloche.
2 réponses
-
Plusieurs points à vérifier:
1)
#include <stdio.h>
au lieu de
#include (stdio.h)
2) int i, j
à chaque instruction, il faut mettre un point virgule
3) tu as fais des boucles infinies, il faut incrémenter tes 2 variables i et j:
while (i < tailleTab1) {
j=0;
while (j < tailleTab2) {
somProd = somProd + tab1[i] * tab2[j];
j++;
}
i++;
} -
Bonjour,
Quelle est ta réponse ? Tu dois chercher les lignes où il y a des erreurs (genre il manque un ; etc.). Si tu n'y arrives pas, relis bien ton cours.
Tu dois pouvoir trouver tout seul. En revanche, si tu as des points à éclaircir, n'hésite pas à demander.
Cdlt,