Programme qui ne marche pas
quent511
-
fiddy Messages postés 11069 Date d'inscription Statut Contributeur Dernière intervention -
fiddy Messages postés 11069 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.
A voir également:
- Programme qui ne marche pas
- Comment fermer un programme qui ne répond pas - Guide
- Programme demarrage windows - Guide
- Cette action ne peut pas être réalisée car le fichier est ouvert dans un autre programme - Guide
- Mettre en veille un programme - Guide
- Message programmé iphone - Guide
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++;
}
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++;
}