Voila mon premier programme :
La division est toujours égale à 0
Pourquoi?
#include <stdlib.h>
int main(int argc, char *argv[])
{
long plus = 0,moins = 0,multi = 0, nombre1 = 0, nombre2 = 0;
float div = 0;
// On demande les nombres 1 et 2 à l'utilisateur :
printf("Entrez le nombre 1 : ");
scanf("%ld", &nombre1);
printf("Entrez le nombre 2 : ");
scanf("%ld", &nombre2);
// On fait le calcul :
plus = nombre1 + nombre2;
moins = nombre1 - nombre2;
multi = nombre1 * nombre2;
div = nombre1 / nombre2;
// Et on affiche les opérations à l'écran :
printf ("L'addition nous donne :\t");
printf ("%ld + %ld = %ld\n", nombre1, nombre2, plus);
printf ("La soustraction nous donne :\t");
printf ("%ld - %ld = %ld\n", nombre1,nombre2, moins);
printf ("La multiplication nous donne :\t");
printf ("%ld * %ld = %ld\n", nombre1, nombre2, multi);
printf ("La division nous donne :\t");
printf ("%ld / %ld = %ld\n", nombre1, nombre2, div);
system("PAUSE");
return 0;
}