Created
June 25, 2017 12:24
-
-
Save Ambratolm/ca6fd6e51dae6c1a547974c63443db8a to your computer and use it in GitHub Desktop.
Ecrire un algorithme qui demande deux nombres à l’utilisateur et l’informe ensuite si leur produit est négatif ou positif ou nul sans réaliser le calcul du produit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
main() | |
{ | |
printf("***********************************************\n"); | |
printf("Signe du produit de deux nombres\n"); | |
printf("***********************************************\n"); | |
float a,b ; | |
int sa=0, sb=0; | |
printf("Entrez le premier nombre: "); | |
scanf("%f", &a); | |
printf("Entrez le deuxième nombre: "); | |
scanf("%f", &b); | |
printf("-----------------------------------------------\n"); | |
if (a != 0 && b != 0) { | |
if (a > 0) { | |
sa = +1; | |
} else { | |
sa = -1; | |
} | |
if (b > 0) { | |
sb = +1; | |
} else { | |
sb = -1; | |
} | |
} else { | |
sa = 0; | |
sb = 0; | |
} | |
if (sa==0 & sb==0) { | |
printf("Le produit n'a pas de signe (0)."); | |
} else if (sa==sb) { | |
printf("Le produit est de signe positif (+)."); | |
} else { | |
printf("Le produit est de signe négatif (-)."); | |
} | |
printf("\n"); | |
system("pause"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment