Solution of URI 1037::Interval
Before seeing the solution make sure that you have tried enough. Don’t copy the whole code, just find out the logic. If you feel any problem, you will inform me by comment.
#include <stdio.h>
int main ()
{
float n;
scanf("%f",&n);
if (n<0 || n>100) {
printf("Fora de intervalo\n");
}
else {
if (n>=0 && n<=25) {
printf("Intervalo [0,25]\n");
}
else if (n>25 && n<=50) {
printf("Intervalo (25,50]\n");
}
else if (n>50 && n<=75) {
printf("Intervalo (50,75]\n");
}
else if (n>75 && n<=100) {
printf("Intervalo (75,100]\n");
}
}
return 0;
}
No comments