Add is_a_number
This commit is contained in:
parent
f3661a2ff7
commit
95705d8ea9
2 changed files with 31 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -40,3 +40,4 @@ sos-crash
|
|||
longueur-chaine
|
||||
calcul-somme-tableau
|
||||
puissance
|
||||
is_a_number
|
||||
|
|
30
programmation-c-cpp/tp5/is_a_number.c
Normal file
30
programmation-c-cpp/tp5/is_a_number.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* Puissance */
|
||||
|
||||
// CECI EST NON FONCTIONNEL
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int is_a_number(int);
|
||||
|
||||
int main() {
|
||||
int entree;
|
||||
|
||||
printf("Écrire un nombre : ");
|
||||
scanf("%d", &entree);
|
||||
|
||||
if (is_a_number(entree)) {
|
||||
printf("C'est un nombre\n");
|
||||
} else {
|
||||
printf("Ce n'est pas un nombre\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int is_a_number(int entree) {
|
||||
if (entree == (char) entree) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
Loading…
Reference in a new issue