Skip to content

Instantly share code, notes, and snippets.

@Ambratolm
Created June 25, 2017 12:19
Show Gist options
  • Save Ambratolm/0d89d2462a20c5a75008dbf65d7bfc42 to your computer and use it in GitHub Desktop.
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.
#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