This code does not seem to have anything to do with the statement. I wrote a code according to what I understood.
Whether it is large or not, even or odd can be discovered by normal checking using comparison is pure mathematics.
Colors need to have a pattern indicating how each number is represented. I created a array with a character representing the color at the position of each number. The array needs to have 37 positions because it goes from 0 to 36. 0 is green, so it deserves treatment differentiation. I didn’t follow the colors that are in the roulette image. If this is important, just change the order arranged in the array, each character is a position. A array which is a string is a string then it’s easier to declare like that. Strictly there is a slight technical problem in doing this, but it will not affect the operation on something so simple.
After typed the value is picked the position of the array according to the typed to choose the color and decide what to write. Then take the rest of 2 to see if it’s even and check if the number is over 18, but I don’t know if this criterion is correct.
It does not have in the statement, but I checked if an invalid value was typed, even because without it, it would be a problem in the code.
#include <stdio.h>
int main(void) {
char cor[37] = "0PVPPVPVVVPPVPVVVVPVPPVPVPPVPVPVPPVPV";
int entrada;
printf("Qual é o número? ");
scanf("%i", &entrada);
if (entrada < 0 || entrada > 36) {
printf("Valor inválido");
return 0;
}
printf("\nO número é %d, é %s", entrada, cor[entrada] == 'V' ? "vermelho" : cor[entrada] == 'P'
? "preto" : "verde");
printf(", %s", entrada > 18 ? "grande" : "pequeno");
printf(", %s", entrada % 2 == 0 ? "par" : "ímpar");
}
Behold working in the ideone. And in the repl it.. Also put on the Github for future reference.
So the code was much simpler than what was being tried. I start by interpreting the text correctly. Then have a mathematical understanding of things. When coding the least you need to know is the syntax of things. The written code had several problems and did not even compile. Even if the logic was this described code year, it still has other logic problems besides syntax errors.
Did the answer solve your problem? Do you think you can accept it? If you don’t know how you do it, check out [tour]. This would help a lot to indicate that the solution was useful to you and to give an indication that there was a satisfactory solution. You can also vote on any question or answer you find useful on the entire site.
– Maniero