Bonjour,
Problèmes :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| 08-12-19.c:4: error: parse error before '{' token
08-12-19.c:10: error: parse error before string constant
08-12-19.c:10: error: stray '\' in program
08-12-19.c:10: warning: type defaults to `int' in declaration of `printf'
08-12-19.c:10: error: conflicting types for 'printf'
08-12-19.c:10: note: a parameter list with an ellipsis can't match an empty para
meter name list declaration
08-12-19.c:10: error: conflicting types for 'printf'
08-12-19.c:10: note: a parameter list with an ellipsis can't match an empty para
meter name list declaration
08-12-19.c:10: warning: data definition has no type or storage class
08-12-19.c:11: error: parse error before string constant
08-12-19.c:11: warning: type defaults to `int' in declaration of `scanf'
08-12-19.c:11: error: conflicting types for 'scanf'
08-12-19.c:11: note: a parameter list with an ellipsis can't match an empty para
meter name list declaration
08-12-19.c:11: error: conflicting types for 'scanf'
08-12-19.c:11: note: a parameter list with an ellipsis can't match an empty para
meter name list declaration
08-12-19.c:11: warning: data definition has no type or storage class
08-12-19.c:12: error: parse error before string constant
08-12-19.c:12: error: stray '\' in program
08-12-19.c:12: warning: type defaults to `int' in declaration of `printf'
08-12-19.c:12: warning: data definition has no type or storage class
08-12-19.c:13: error: parse error before string constant
08-12-19.c:13: warning: type defaults to `int' in declaration of `scanf'
08-12-19.c:13: warning: data definition has no type or storage class
08-12-19.c:14: error: parse error before string constant
08-12-19.c:14: error: stray '\' in program
08-12-19.c:14: warning: type defaults to `int' in declaration of `printf'
08-12-19.c:14: warning: data definition has no type or storage class
08-12-19.c:15: error: parse error before string constant
08-12-19.c:15: warning: type defaults to `int' in declaration of `scanf'
08-12-19.c:15: warning: data definition has no type or storage class
08-12-19.c:16: error: `a' undeclared here (not in a function)
08-12-19.c:16: error: parse error before ';' token
08-12-19.c:17: error: initializer element is not constant
08-12-19.c:18: error: parse error before string constant
08-12-19.c:18: warning: type defaults to `int' in declaration of `printf'
08-12-19.c:18: warning: data definition has no type or storage class
08-12-19.c:19: error: parse error before string constant
08-12-19.c:19: warning: type defaults to `int' in declaration of `printf'
08-12-19.c:19: warning: data definition has no type or storage class
08-12-19.c:20: error: parse error before string constant
08-12-19.c:20: warning: type defaults to `int' in declaration of `printf'
08-12-19.c:20: warning: data definition has no type or storage class
08-12-19.c:21: error: parse error before string constant
08-12-19.c:21: warning: type defaults to `int' in declaration of `printf'
08-12-19.c:21: warning: data definition has no type or storage class |
D'où ça vient ?
Pas de ; après entre le prototype est la définition de la fonction.
printf("Entrez la hauteur du tremplin: "\n);
\n doit être avant le "
1 2 3
| float v;
/* ... */
float v = ...; |
Redéfinition de v. le second float est de trop
float v=sqrt((d*10)/(2*(b/(sqrt((a*a)+(b*b))))*(a/(sqrt((a*a)+(b*b)))));
manque une parenthèse fermante.
%d : pour les entiers, %f pour les flottants.
Si on corrige les fautes et qu'on indente un peu, on obtient :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| #include <math.h>
#include <stdio.h>
int main(void)
{
int a;
int b;
int d;
float v;
float w;
printf("Entrez la hauteur du tremplin: \n");
scanf("%d", &a);
printf("Entrez la longueur du tremplin: \n");
scanf("%d", &b);
printf("Entrez la longueur du saut: \n");
scanf("%d", &d);
v = sqrt((d * 10) /
(2 * (b / (sqrt((a * a) + (b * b)))) *
(a / (sqrt((a * a) + (b * b))))));
w = sqrt(
((10 * ((d + b) * (d + b))) -
(2 * a)) / (2 * (d + b)
* (b / (sqrt((a * a) + (b * b))))
* (a / (sqrt((a * a) + (b * b))))));
printf("Votre vitesse doit être comprise entre ");
printf("%f", v);
printf(" et ");
printf("%f", w);
return 0;
} |
Partager