begin process at 2012 02 12 12:45:19
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Maths & Algorithmes

 > UNE PETITE CALCULETTE [DEV-C++]

UNE PETITE CALCULETTE [DEV-C++]


 Information sur la source

Note :
1 / 10 - par 1 personne
1,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Maths & Algorithmes Niveau :Débutant Date de création :18/03/2002 Date de mise à jour :07/04/2002 13:10:59 Vu / téléchargé :3 105 / 108

Auteur : gorgonzola

Ecrire un message privé
Site perso
Commentaire sur cette source (0)
Ajouter un commentaire et/ou une note

 Description

Cliquez pour voir la capture en taille normale
Bon ben une simple calculette, le code est long mais tres simple, elle peut faire pas mal de truc, ainsi qu'afficher la table d'un nombre demande (c'est pas tres utile mais bon...)
  

Source

  • #include <stdio.h>
  • void main()
  • {
  • float nombre1;
  • float nombre2;
  • int increment=1;
  • int choix;
  • double fact;
  • while (increment==1)
  • {
  • printf("######################################################\n");
  • printf("#---------------------CALCULETTE---------------------#\n");
  • printf("######################################################\n\n");
  • printf("Choisissez une categorie :\n\n");
  • printf("1. additions 5. exposants\n");
  • printf("2. soustractions 6. factoriels\n");
  • printf("3. multiplications 7. tables de multiplications\n");
  • printf("4. divisions 8. quitter\n\n");
  • scanf("%d",&choix);
  • while ( (choix < 1) || (choix > 8) )
  • {
  • printf("\nERREUR : veuillez entrer un nombre de 1 a 8 ! ");
  • scanf("%d",&choix);
  • }
  • while (choix == 1)
  • {
  • printf("\nEntrez un premier nombre : ");
  • scanf("%f",&nombre1);
  • printf("\nEntrez un second nombre : ");
  • scanf("%f",&nombre2);
  • printf("\n%.3f + %.3f = %.3f\n\n",nombre1,nombre2,(nombre1+nombre2));
  • printf("Faites 1 pour refaire une addition et 2 pour revenir au menu : ");
  • scanf("%d",&choix);
  • while ( (choix < 1) || (choix > 2) )
  • {
  • printf("\nERREUR : veuillez entrer 1 ou 2 ! ");
  • scanf("%d",&choix);
  • }
  • if (choix==2) choix=0;
  • if (choix==1) choix=1;
  • }
  • while (choix == 2)
  • {
  • printf("\nEntrez un premier nombre : ");
  • scanf("%f",&nombre1);
  • printf("\nEntrez un second nombre : ");
  • scanf("%f",&nombre2);
  • printf("\n%.3f - %.3f = %.3f\n\n",nombre1,nombre2,(nombre1-nombre2));
  • printf("Faites 1 pour refaire une soustraction et 2 pour revenir au menu : ");
  • scanf("%d",&choix);
  • while ( (choix < 1) || (choix > 2) )
  • {
  • printf("\nERREUR : veuillez entrer 1 ou 2 ! ");
  • scanf("%d",&choix);
  • }
  • if (choix==2) choix=0;
  • if (choix==1) choix=2;
  • }
  • while (choix == 3)
  • {
  • printf("\nEntrez un premier nombre : ");
  • scanf("%f",&nombre1);
  • printf("\nEntrez un second nombre : ");
  • scanf("%f",&nombre2);
  • printf("\n%.3f x %.3f = %.3f\n\n",nombre1,nombre2,(nombre1*nombre2));
  • printf("Faites 1 pour refaire une multiplication et 2 pour revenir au menu : ");
  • scanf("%d",&choix);
  • while ( (choix < 1) || (choix > 2) )
  • {
  • printf("\nERREUR : veuillez entrer 1 ou 2 ! ");
  • scanf("%d",&choix);
  • }
  • if (choix==2) choix=0;
  • if (choix==1) choix=3;
  • }
  • while (choix == 4)
  • {
  • printf("\nEntrez un premier nombre : ");
  • scanf("%f",&nombre1);
  • printf("\nEntrez un second nombre : ");
  • scanf("%f",&nombre2);
  • printf("\n%.3f : %.3f = %.3f\n\n",nombre1,nombre2,(nombre1/nombre2));
  • printf("Faites 1 pour refaire une division et 2 pour revenir au menu : ");
  • scanf("%d",&choix);
  • while ( (choix < 1) || (choix > 2) )
  • {
  • printf("\nERREUR : veuillez entrer 1 ou 2 ! ");
  • scanf("%d",&choix);
  • }
  • if (choix==2) choix=0;
  • if (choix==1) choix=4;
  • }
  • while (choix==5)
  • {
  • printf("\nEntrez un nombre : ");
  • scanf("%f",&nombre1);
  • printf("\nEntrez son exposant : ");
  • scanf("%d",&choix);
  • while ( (nombre1 == 0) && (choix < 1) )
  • {
  • printf("\nERREUR : il est impossible de calculer un exposant\n");
  • printf(" plus petit que 1 pour le nombre zero\n");
  • printf(" car cela reviendrait a diviser zero par zero, ce qui\n");
  • printf(" conduit a une aberration.\n\n");
  • printf("Veuillez donc entrer un autre exposant pour zero : ");
  • scanf("%d",&choix);
  • }
  • nombre2=1;
  • if (choix < 0)
  • {
  • for (increment=0 ; increment > choix ; increment--) nombre2=nombre2/nombre1;
  • }
  • if (choix >= 0)
  • {
  • for (increment=0 ; increment < choix ; increment++) nombre2=nombre2*nombre1;
  • }
  • printf("\n%.3f exposant %d = %.3f\n\n",nombre1,choix,nombre2);
  • printf("Faites 1 pour refaire l'exposant d'un nombre et 2 pour revenir au menu : ");
  • scanf("%d",&choix);
  • while ( (choix < 1) || (choix > 2) )
  • {
  • printf("\nERREUR : veuillez entrer 1 ou 2 ! ");
  • scanf("%d",&choix);
  • }
  • increment=1;
  • if (choix==2) choix=0;
  • if (choix==1) choix=5;
  • }
  • while (choix==6)
  • {
  • printf("\nEntrez un nombre : ");
  • scanf("%d",&choix);
  • while ( (choix < 0) || (choix > 170) )
  • {
  • printf("\nERREUR : veuillez entrer un nombre entier positif pas plus grand que 170 ! ");
  • scanf("%d",&choix);
  • }
  • fact=1;
  • for (increment=1 ; increment <= choix ; increment++) fact=fact*increment;
  • printf("\n%d! = %.0f\n\n",choix,fact);
  • printf("Faites 1 pour refaire un factoriel et 2 pour revenir au menu : ");
  • scanf("%d",&choix);
  • while ( (choix < 1) || (choix > 2) )
  • {
  • printf("\nERREUR : veuillez entrer 1 ou 2 ! ");
  • scanf("%d",&choix);
  • }
  • increment=1;
  • if (choix==2) choix=0;
  • if (choix==1) choix=6;
  • }
  • while (choix==7)
  • {
  • printf("\nVous voulez la table de quelle nombre ? ");
  • scanf("%f",&nombre1);
  • printf("\nVous la voulez jusqu'ou ? ");
  • scanf("%d",&choix);
  • printf("\n");
  • while (choix > 250)
  • {
  • printf("ERREUR : veuillez ne pas depasser 250 ! ");
  • scanf("%d",&choix);
  • }
  • for (increment=1 ; increment<=choix ; increment++) printf("%3d x %.3f = %.3f\n",increment,nombre1,(nombre1*increment));
  • printf("\n\nFaites 1 pour refaire une table de multiplication et 2 pour revenir au menu : ");
  • scanf("%d",&choix);
  • while ( (choix < 1) || (choix > 2) )
  • {
  • printf("\nERREUR : veuillez entrer 1 ou 2 ! ");
  • scanf("%d",&choix);
  • }
  • increment=1;
  • if (choix==2) choix=0;
  • if (choix==1) choix=7;
  • }
  • if (choix==8) increment=0;
  • }
  • }
#include <stdio.h>

void main()
{
  float  nombre1;
  float  nombre2;
  int    increment=1;
  int    choix;
  double fact;

  while (increment==1)
  {
    printf("######################################################\n");
    printf("#---------------------CALCULETTE---------------------#\n");
    printf("######################################################\n\n");
    printf("Choisissez une categorie :\n\n");
    printf("1. additions             5. exposants\n");         
    printf("2. soustractions         6. factoriels\n");
    printf("3. multiplications       7. tables de multiplications\n");
    printf("4. divisions             8. quitter\n\n");
    scanf("%d",&choix);
    while ( (choix < 1) || (choix > 8) )
    {
      printf("\nERREUR : veuillez entrer un nombre de 1 a 8 ! ");
      scanf("%d",&choix);
    }
    while (choix == 1)
    {
      printf("\nEntrez un premier nombre : ");
      scanf("%f",&nombre1);
      printf("\nEntrez un second nombre : ");
      scanf("%f",&nombre2);
      printf("\n%.3f + %.3f = %.3f\n\n",nombre1,nombre2,(nombre1+nombre2));
      printf("Faites 1 pour refaire une addition et 2 pour revenir au menu : ");
      scanf("%d",&choix);
      while ( (choix < 1) || (choix > 2) )
      {
        printf("\nERREUR : veuillez entrer 1 ou 2 ! ");
        scanf("%d",&choix);
      }
      if (choix==2) choix=0;
      if (choix==1) choix=1;
    } 
    while (choix == 2)
    {
      printf("\nEntrez un premier nombre : ");
      scanf("%f",&nombre1);
      printf("\nEntrez un second nombre : ");
      scanf("%f",&nombre2);
      printf("\n%.3f - %.3f = %.3f\n\n",nombre1,nombre2,(nombre1-nombre2));
      printf("Faites 1 pour refaire une soustraction et 2 pour revenir au menu : ");
      scanf("%d",&choix);
      while ( (choix < 1) || (choix > 2) )
      {
        printf("\nERREUR : veuillez entrer 1 ou 2 ! ");
        scanf("%d",&choix);
      }
      if (choix==2) choix=0;
      if (choix==1) choix=2;
    } 
    while (choix == 3)
    {
      printf("\nEntrez un premier nombre : ");
      scanf("%f",&nombre1);
      printf("\nEntrez un second nombre : ");
      scanf("%f",&nombre2);
      printf("\n%.3f x %.3f = %.3f\n\n",nombre1,nombre2,(nombre1*nombre2));
      printf("Faites 1 pour refaire une multiplication et 2 pour revenir au menu : ");
      scanf("%d",&choix);
      while ( (choix < 1) || (choix > 2) )
      {
        printf("\nERREUR : veuillez entrer 1 ou 2 ! ");
        scanf("%d",&choix);
      }
      if (choix==2) choix=0;
      if (choix==1) choix=3;
    } 
    while (choix == 4)
    {
      printf("\nEntrez un premier nombre : ");
      scanf("%f",&nombre1);
      printf("\nEntrez un second nombre : ");
      scanf("%f",&nombre2);
      printf("\n%.3f : %.3f = %.3f\n\n",nombre1,nombre2,(nombre1/nombre2));
      printf("Faites 1 pour refaire une division et 2 pour revenir au menu : ");
      scanf("%d",&choix);
      while ( (choix < 1) || (choix > 2) )
      {
        printf("\nERREUR : veuillez entrer 1 ou 2 ! ");
        scanf("%d",&choix);
      }
      if (choix==2) choix=0;
      if (choix==1) choix=4;
    } 
    while (choix==5)
    {
      printf("\nEntrez un nombre : ");
      scanf("%f",&nombre1);
      printf("\nEntrez son exposant : ");
      scanf("%d",&choix);
      while ( (nombre1 == 0) && (choix < 1) )
      {
        printf("\nERREUR : il est impossible de calculer un exposant\n");
        printf("         plus petit que 1 pour le nombre zero\n");
        printf("         car cela reviendrait a diviser zero par zero, ce qui\n"); 
        printf("         conduit a une aberration.\n\n");
        printf("Veuillez donc entrer un autre exposant pour zero : ");
        scanf("%d",&choix);
      } 
      nombre2=1;
      if (choix < 0)
      {
      for (increment=0 ; increment > choix ; increment--) nombre2=nombre2/nombre1;
      }
      if (choix >= 0)
      {
      for (increment=0 ; increment < choix ; increment++) nombre2=nombre2*nombre1;
      }
      printf("\n%.3f exposant %d = %.3f\n\n",nombre1,choix,nombre2);
      printf("Faites 1 pour refaire l'exposant d'un nombre et 2 pour revenir au menu : ");
      scanf("%d",&choix);
      while ( (choix < 1) || (choix > 2) )
      {
        printf("\nERREUR : veuillez entrer 1 ou 2 ! ");
        scanf("%d",&choix);
      }
      increment=1;
      if (choix==2) choix=0;
      if (choix==1) choix=5;
    } 
    while (choix==6)
    {
      printf("\nEntrez un nombre : ");
      scanf("%d",&choix);
      while ( (choix < 0) || (choix > 170) )
      {
        printf("\nERREUR : veuillez entrer un nombre entier positif pas plus grand que 170 ! ");
        scanf("%d",&choix);
      }
      fact=1;
      for (increment=1 ; increment <= choix ; increment++) fact=fact*increment;
      printf("\n%d! = %.0f\n\n",choix,fact);
      printf("Faites 1 pour refaire un factoriel et 2 pour revenir au menu : ");
      scanf("%d",&choix);
      while ( (choix < 1) || (choix > 2) )
      {
        printf("\nERREUR : veuillez entrer 1 ou 2 ! ");
        scanf("%d",&choix);
      }
      increment=1;
      if (choix==2) choix=0;
      if (choix==1) choix=6;
    } 
    while (choix==7)
    {
      printf("\nVous voulez la table de quelle nombre ? ");
      scanf("%f",&nombre1);
      printf("\nVous la voulez jusqu'ou ? ");
      scanf("%d",&choix);
      printf("\n");
      while (choix > 250)
      {
        printf("ERREUR : veuillez ne pas depasser 250 ! ");
        scanf("%d",&choix);
      }
      for (increment=1 ; increment<=choix ; increment++) printf("%3d x %.3f = %.3f\n",increment,nombre1,(nombre1*increment));
      printf("\n\nFaites 1 pour refaire une table de multiplication et 2 pour revenir au menu : ");
      scanf("%d",&choix);
      while ( (choix < 1) || (choix > 2) )
      {
        printf("\nERREUR : veuillez entrer 1 ou 2 ! ");
        scanf("%d",&choix);
      }
      increment=1;
      if (choix==2) choix=0;
      if (choix==1) choix=7;
    }
    if (choix==8) increment=0;        
  }
}  

 Conclusion

voila c'est tout  

 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Sources du même auteur

Source avec Zip Source avec une capture RESOLUTION D'EQUATIONS (JUSQU'AU 3EME DEGRE) + CLASSE POUR M...
Source avec Zip DESSINER A LA MAIN UNE STRUCTURE FRACTALE [DJGPP] [VGA 13H]
Source avec Zip JEU DE LA VIE EN MODE VGA 11H [DJGPP]
Source avec Zip Source avec une capture GENERATEUR DE FRACTAL PERSONNALISE [VESA] [DJGPP]
Source avec Zip MODE VESA HAUTE RESOLUTION [DJGPP]

 Sources de la même categorie

Source avec Zip UN EXAMPLE D'APPLICATION EN CUDA DE L'ALGORITHME DE SCAN POU... par oguzaras
Source avec Zip Source avec une capture CHIFFREMENT DE VIGENERE par lajouad
Source avec Zip Source avec une capture ANALYSE SYNTAXIQUE par lajouad
Source avec Zip Source avec une capture STRUCTURE D'UNE MATRICE PAR LES LISTE LINÉAIRE (NON CONTUGUS... par benzarabel
Source avec Zip Source avec une capture DESSINER UNE ARBRE BINAIRE( MODE CONSOLE): par benzarabel

Commentaires et avis

Aucun commentaire pour le moment.

 Ajouter un commentaire




Nos sponsors


Sondage...

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,889 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales