CONNEXION
  • RetourJeux
    • Sorties
    • Hit Parade
    • Les + populaires
    • Les + attendus
    • Soluces
    • Tous les Jeux
    • Gaming
  • RetourActu Gaming
    • News
    • Astuces
    • Tests
    • Previews
    • Toute l'actu gaming
  • RetourBons plans
    • Bons plans
    • Bons plans Smartphone
    • Bons plans Hardware
    • Bons plans Image et Son
    • Bons plans Amazon
    • Bons plans Cdiscount
    • Bons plans Decathlon
    • Bons plans Fnac
    • Tous les Bons plans
  • RetourJVTech
    • Actus High-Tech
    • Intelligence Artificielle
    • Smartphones
    • Mobilité urbaine
    • Hardware
    • Image et son
    • Tutoriels
    • Tests produits High-Tech
    • Guides d'achat High-Tech
    • JVTech
  • RetourCulture
    • Actus Culture
    • Culture
  • RetourVidéos
    • A la une
    • Gaming Live
    • Vidéos Tests
    • Vidéos Previews
    • Gameplay
    • Trailers
    • Chroniques
    • Replay Web TV
    • Toutes les vidéos
  • RetourForums
    • Hardware PC
    • PS5
    • Switch 2
    • Xbox Series
    • Switch
    • Pokemon pocket
    • FC 25 Ultimate Team
    • League of Legends
    • Tous les Forums
  • PC
  • PS5
  • Xbox Series
  • Switch 2
  • PS4
  • One
  • Switch
  • iOS
  • Android
  • MMO
  • RPG
  • FPS
En ce moment Genshin Impact Valhalla Breath of the wild Animal Crossing GTA 5 Red dead 2
Liste des sujets

pascal, probleme de code source

nicolas1992
nicolas1992
Niveau 6
15 octobre 2008 à 20:25:46

Bonjour,
Voici mon code source, pouvez vous me dire ce qu'il cloche? C'est pour faire une calculatrice .
merci d'avance.
Code :

Program Calculatrice;
Var a: integer; b, c, d: real;
Begin
WriteLn
('-------------------Calculatrice-----------------
--');
WriteLn;
WriteLn ('1. Addition');
WriteLn ('2. Soustraction');
WriteLn ('3. Division');
WriteLn ('4. Multiplication');
WriteLn;
WriteLn ('Entrer le chiffre qui correspond a ce que vous voulez faire:');
ReadLn (a);
Case a of
1: WriteLn (' Entrez un premier nombre:');

WriteLn (' Entrez un second nombre:');
ReadLn (c);
d:=a+b;
WriteLn ('La réponse est:');
WriteLn (d);
2: WriteLn (' Entrez un premier nombre:');
ReadLn (b);
WriteLn (' Entrez un second nombre:');
ReadLn (c);
d:=a-b;
WriteLn ('La réponse est:');
WriteLn (d);
3: WriteLn (' Entrez un premier nombre:');
ReadLn (b);
WriteLn (' Entrez un second nombre:');
ReadLn (c);
d:=a/b;
WriteLn ('La réponse est:');
WriteLn (d);
4: WriteLn(' Entrez un premier nombre:');
ReadLn (b);
WriteLn(' Entrez un second nombre:');
ReadLn (c);
d:=a*b;
WriteLn ('La réponse est:');
WriteLn (d);
End;

ReadLn
End.

Trooper04
Trooper04
Niveau 29
15 octobre 2008 à 21:48:46

Déja, il te manque un read pour l'addition.
Ensuite si tu lis b et c, c'est pas pour faire
d := a op b;

mais

d := b op c;

:ok:

nicolas1992
nicolas1992
Niveau 6
16 octobre 2008 à 16:56:40

merci pour ta réponse, j'ai deja rectifier ce que tu ma fais remarqué mais j'ai encore 3 erreurs dans mon code:
16 / 16 calcul~1.pas
Error: Constant and CASE types do not match

16 / 16 calcul~1.pas
Error: Ordinal expression expected

16 / 16 calcul~1.pas
Fatal: Syntax error, : expected but ; found

Je vois vraiment pas d'ou ça viens. Mon code:

Program Calculatrice;
Var a: integer; b, c, d: real;
Begin
WriteLn
('-------------------Calculatrice-----------------
--');
WriteLn;
WriteLn ('1. Addition');
WriteLn ('2. Soustraction');
WriteLn ('3. Division');
WriteLn ('4. Multiplication');
WriteLn;
WriteLn ('Entrer le chiffre qui correspond a ce que vous voulez faire:');
ReadLn (a);
Case a of

2: WriteLn (' Entrez un premier nombre:');
ReadLn (b);
WriteLn (' Entrez un second nombre:');
ReadLn (c);
d:=b-c;
WriteLn ('La réponse est:');
WriteLn (d);
3: WriteLn (' Entrez un premier nombre:');
ReadLn (b);
WriteLn (' Entrez un second nombre:');
ReadLn (c);
d:=b/c;
WriteLn ('La réponse est:');
WriteLn (d);
4: WriteLn(' Entrez un premier nombre:');
ReadLn (b);
WriteLn(' Entrez un second nombre:');
ReadLn (c);
d:=b*c;
WriteLn ('La réponse est:');
WriteLn (d);
End;

ReadLn
End.

Trooper04
Trooper04
Niveau 29
17 octobre 2008 à 14:20:57

Il manque un case pour a=1.

Réécris tes case avec des begin-end et n'oublie pas le end de fin de case :

case a of

1:begin
...
end;

2:begin
...
end;

3:begin
WriteLn (' Entrez un premier nombre:');
ReadLn (b);
WriteLn (' Entrez un second nombre:');
ReadLn (c);
d:=b/c;
WriteLn ('La réponse est:');
WriteLn (d);
end;

4:begin
...
end;

end;

Sous forums
  • Aide à l'achat Mac
  • Macintosh
  • Création de sites web
  • Création de Jeux
  • Linux
  • Programmation
  • Internet
  • Steam Deck
  • Hardware
La vidéo du moment