1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#include <stdio.h>
static void fpurge (FILE * fp)
{
int c;
while ((c = fgetc (fp)) != '\n' && c != EOF)
{
}
}
int main (void)
{
int N, i = 0, produit, Borne_Inf = 0, Borne_Sup = 20;
do
{
N = -1;
printf
("Tapez l'entier compris entre 0 et 20 dont vous voulez la table de multiplication \n");
/* pas de test pour le caractere entier scanf(%d) prend seulement la partie entiere */
scanf ("%d", &N);
fpurge (stdin);
if (N < Borne_Inf || N > Borne_Sup)
{
printf ("L'entier choisit n'est pas compris entre 0 et 20!\n");
}
}
while (N < Borne_Inf || N > Borne_Sup);
for (i = Borne_Inf; i <= Borne_Sup; i++)
{
produit = i * N;
printf ("%d x %d = %d\n", N, i, produit);
}
return 0;
} |
Partager