salut à tous , jais fait un petit programme en C comme TP, il permet de faire des calculs : addition multiplication soustraction et division, bref des truc basiques. mais le problème c'est que lors de la compilation il ya des erreures, notamen pour "Case"
voila donc le code :
Code:
#include <stdio.h> #include <stdlib.h>
int main(int argc, char *argv[]) { printf(" ---------------------\n"); printf("| .-=FIRST PROGRAM v1.0=-. |\n"); printf(" ---------------------\n\n\n"); printf("Please select your choice : "); char choice; scanf("%ld", &choice); printf("\n\n1- Addition\n2- Multiplication\n3- Subtraction\n4- Division\n\n\n"); switch(choice) { case 1: float chiffre1, chiffre2; printf("Enter the first number : "); scanf("%lf", &chiffre1); printf("\nEnter the second number : "); scanf("%lf", &chiffre2); float resultat = chiffre1 + chiffre2; printf("\nResult of %lf + %lf is = %lf", chiffre1, chiffre2, resultat); break; case 2: float chiffre3, chiffre4; printf("Enter the first number : "); scanf("%lf", &chiffre3); printf("\nEnter the second number : "); scanf("%lf", &chiffre4); float resultat2 = chiffre3 * chiffre4; printf("\nResult of %lf + %lf is = %lf", chiffre3, chiffre4, resultat2); break; case 3: float chiffre5, chiffre6; printf("Enter the first number : "); scanf("%lf", &chiffre5); printf("\nEnter the second number : "); scanf("%lf", &chiffre6); float resultat3 = chiffre5 - chiffre6; printf("\nResult of %lf + %lf is = %lf", chiffre5, chiffre6, resultat3); break; case 4: float chiffre7, chiffre8; printf("Enter the first number : "); scanf("%lf", &chiffre7); printf("\nEnter the second number : "); scanf("%lf", &chiffre8); float resultat4 = chiffre7 / chiffre8; printf("\nResult of %lf + %lf is = %lf", chiffre7, chiffre8, resultat4); break; } system("PAUSE"); printf("\n\n\nThis was : FIRST PROGRAM v1.0 by t0Xic.h\n\n\n"); system("PAUSE"); return 0; }
vous auriez des idées ? ----------------------------------------------------------------------------------------------------- PS :J'utilise Dev C++ Voila le log de compilation
Code:
Compilateur: Default compiler Exécution de g++.exe... g++.exe "D:\Documents and Settings\M\Bureau\C\Projet 1\Source\FIRST PROGRAM v1.0.cpp" -o "D:\Documents and Settings\M\Bureau\C\Projet 1\Source\FIRST PROGRAM v1.0.exe" -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" D:\Documents and Settings\M\Bureau\C\Projet 1\Source\FIRST PROGRAM v1.0.cpp: In function `int main(int, char**)': D:\Documents and Settings\M\Bureau\C\Projet 1\Source\FIRST PROGRAM v1.0.cpp:34: error: jump to case label D:\Documents and Settings\M\Bureau\C\Projet 1\Source\FIRST PROGRAM v1.0.cpp:31: error: crosses initialization of `float resultat' D:\Documents and Settings\M\Bureau\C\Projet 1\Source\FIRST PROGRAM v1.0.cpp:44: error: jump to case label D:\Documents and Settings\M\Bureau\C\Projet 1\Source\FIRST PROGRAM v1.0.cpp:41: error: crosses initialization of `float resultat2' D:\Documents and Settings\M\Bureau\C\Projet 1\Source\FIRST PROGRAM v1.0.cpp:31: error: crosses initialization of `float resultat'
D:\Documents and Settings\M\Bureau\C\Projet 1\Source\FIRST PROGRAM v1.0.cpp:54: error: jump to case label D:\Documents and Settings\M\Bureau\C\Projet 1\Source\FIRST PROGRAM v1.0.cpp:51: error: crosses initialization of `float resultat3' D:\Documents and Settings\M\Bureau\C\Projet 1\Source\FIRST PROGRAM v1.0.cpp:41: error: crosses initialization of `float resultat2' D:\Documents and Settings\M\Bureau\C\Projet 1\Source\FIRST PROGRAM v1.0.cpp:31: error: crosses initialization of `float resultat'
Exécution terminée
le problème ne **orthographe !** pas que de case apparament mais bon...
merci d'avance
|