maxime61210
Coder
as the title says, sometimes my code doesn't let me enter a character if it is asked too earlier in the program. I know that it's not a big deal and that i could just let the upper part in commentary to test the bottom part, but i feel like i'm missing something i should know...
[CODE lang="c" title="code" highlight="9"]printf("Calculatrice de longueur de l'hypothénuse :\n");
printf("Longueur de l'adjacent :\n");
scanf("%f", &k);
printf("Longueur de l'opposé :\n");
scanf("%f", &l);
printf("Longueur de l'hypothénuse : %f\n", sqrt(k*k+l*l));
printf("entrez un caractère en minuscule : \n");
scanf("%c", &e);
if(e=='a'||e=='e'||e=='i'||e=='o'||e=='u'||e=='y')
{
printf("ce caractère est une voyelle\n");
}
else
{
printf("ce caractère est une consonne\n");
}[/CODE]
this returns, in the terminal :
Calculatrice de longueur de l'hypothénuse :
Longueur de l'adjacent :
9
Longueur de l'opposé :
9
Longueur de l'hypothénuse : 12.727922
entrez un caractère en minuscule : <<<<<<i'm supposed to enter a character, but it wont let me and keeps going...
ce caractère est une consonne
...Program finished with exit code 0
Press ENTER to exit console.
however, if i put the top part (the hypothenus calculus) in commentary, the bottom part (determining if a letter is a consonant or a vowel) works just fine (it lets me enter a character).
thanks a lot for your help !
[CODE lang="c" title="code" highlight="9"]printf("Calculatrice de longueur de l'hypothénuse :\n");
printf("Longueur de l'adjacent :\n");
scanf("%f", &k);
printf("Longueur de l'opposé :\n");
scanf("%f", &l);
printf("Longueur de l'hypothénuse : %f\n", sqrt(k*k+l*l));
printf("entrez un caractère en minuscule : \n");
scanf("%c", &e);
if(e=='a'||e=='e'||e=='i'||e=='o'||e=='u'||e=='y')
{
printf("ce caractère est une voyelle\n");
}
else
{
printf("ce caractère est une consonne\n");
}[/CODE]
this returns, in the terminal :
Calculatrice de longueur de l'hypothénuse :
Longueur de l'adjacent :
9
Longueur de l'opposé :
9
Longueur de l'hypothénuse : 12.727922
entrez un caractère en minuscule : <<<<<<i'm supposed to enter a character, but it wont let me and keeps going...
ce caractère est une consonne
...Program finished with exit code 0
Press ENTER to exit console.
however, if i put the top part (the hypothenus calculus) in commentary, the bottom part (determining if a letter is a consonant or a vowel) works just fine (it lets me enter a character).
thanks a lot for your help !