Created
June 25, 2017 12:19
-
-
Save Ambratolm/0d89d2462a20c5a75008dbf65d7bfc42 to your computer and use it in GitHub Desktop.
Ecrire l’algorithme qui Détermine si un nombre entier est pair ou impair.
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("Déterminer si un nombre entier est pair ou impair\n"); | |
printf("**************************\n"); | |
printf("\n"); | |
int n , q, r ; | |
printf("Entrez un nombre entier: "); | |
scanf("%d", &n); | |
q = n/2 ; | |
r = n%2 ; | |
printf("-------------------------\n"); | |
printf("\n"); | |
if (r==0) { | |
printf("Le nombre %d est pair.\nSa moitié est %d.\n", n,q); | |
} else { | |
printf("Le nombre %d est impair.\nIl en reste %d de sa division en deux d'un quotient de %d.\n", n,r,q); | |
} | |
printf("\n"); | |
printf("-------------------------\n"); | |
printf("\n"); | |
system("pause"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment