0
I’m a beginner in C. I need the program below to read the number typed in console and give tips to the user until he gets it right:
#include <stdio.h>
int main ()
{
int num;
printf("Informe um número entre 0 e 10:\n");
scanf("%d",&num);
while (num!=7)
{
printf("Escolha outro valor:");
scanf("%d",&num);
switch(num)
{
case '0':
printf("Tente outro numero\n");
break;
case '1':
printf("Escolha outro valor\n");
break;
case '2':
printf("Esta longe, tente outro\n");
break;
case '3':
printf("O numero e maior\n");
break;
case '4':
printf("Tente novamente\n");
break;
case '5':
printf("Esta proximo, mas ainda nao e este\n");
break;
case '6':
printf("Ja pensou em tentar um numero impar?\n");
break;
case '8':
printf("Esta proximo\n");
break;
case '9':
printf("Tente um valor menor\n");
break;
case '10':
printf("E um numero menor\n");
break;
default:
printf("Voce acertou");
break;
}
}
}
Dear @user31057, read on tour and edit your question succinctly, so the community can help with your doubt but not do your exercise.
– Marcelo de Andrade
What is your doubt?
– DaviAragao
When I go to compile I can’t get him to repeat
– user31057
Sorry for the ignorance (I’m new to programming), but it is no longer among keys?
– user31057
Just take out the Simple Quotes that will work.
– Renan Noronha