0
I’m solving college exercises, but I got caught up in one:
The exercise asks me to calculate the even numbers between two integers, and that at the end, I do the arithmetic mean between the pairs.
What I’ve done so far:
int main()
{
int numeroum, numerodois;
printf("Insira dois números pares\n");
scanf("%d", &numeroum);
scanf("%d", &numerodois);
printf("Os pares entre %d e %d são: \n", numeroum, numerodois);
while (numeroum < numerodois) {
printf("%d\n", numeroum);
numeroum = numeroum + 2;
}
printf("A média de todos os números é: %d\n", );
return 0;
}
Do you want help in logic? Or some doubt in the code (commands)?
– Andrey
How about
printf("%d", (((numeroum + 1) & ~1) + (numerodois & ~1)) / 2);
?– Victor Stafusa
@Andrey Part in the code and part in the logic, but more in the code. I don’t know exactly which command to use to have a split of the While results.
– steeph
@Victorstafusa I tried with this command and it didn’t work... I didn’t get to work with ~ yet, I’m not sure what it would serve... if I’m right, sorry, but I’m pretty layman hahahaah
– steeph