Last active
June 25, 2017 12:12
-
-
Save Ambratolm/34cebe6ba01452f293b6f1f49dc09e1e to your computer and use it in GitHub Desktop.
Écrire l’algorithme qui lit 3 nombres et qui teste si l’un de ces derniers est égal à la somme des deux autres. Si un tel nombre existe on l’affiche, sinon on affiche un message.
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("Test de 3 nombres et comparaison\n"); | |
printf("\n"); | |
float a,b,c; //a+b=c? a+c=b? b+c=a? | |
printf("Entrez le 1er nombre: "); | |
scanf("%f",&a); | |
printf("Entrez le 2eme nombre: "); | |
scanf("%f",&b); | |
printf("Entrez le 3eme nombre: "); | |
scanf("%f",&c); | |
printf("\n"); | |
if (a==b+c) | |
{ | |
printf("%f est la somme de %f et %f", a,b,c); | |
} | |
else if (b==a+c) | |
{ | |
printf("%f est la somme de %f et %f", b,a,c); | |
} | |
else if (c==a+b) | |
{ | |
printf("%f est la somme de %f et %f", c,a,b); | |
} | |
else | |
{ | |
printf("\nAucune relation de somme trouvée entre les nombres"); | |
} | |
printf("\n"); | |
system("pause"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment