I solved other problems, I formatted better for easier reading. See that even seeming silly, the spaces, the punctuation, everything helps.
If the problem is to keep repeating the request until an invalid value is typed then you should only put inside the repeat what needs to be done again and the only thing that needs to be done again is the typing request. The rest stay out of the loop.
And if you must stay within the loop while the condition is invalid, you must invert the operator than it is valid. That is, if you need the value to be > 1
, it should be stuck as invalid if the value is <= 1
.
And this is another important learning experience. The opposite of >
is <=
and not <
as many may think. Obviously the opposite of <
is >=
. If the opposite of >
was <
, then the equal value would be what? Would I be lost in space? The equal has to enter on one side.
#include <stdio.h>
int main() {
int num = 1, primo;
do {
printf("Informe um numero primo maior que 1:");
scanf("%d", &primo);
} while (primo <= 1);
if (primo % num == 0) {
printf("Numero primo %d", primo);
} else {
printf("Numero não primo");
}
}
See running on ideone .
That's not the way the cousin is, but I'll let you fix it because it's not the focus of the question.