Sorry for the lack of variable names. But the modulus operator % worked, thanks.
I was trying to calculate the day by inputting day of the year (1-365), I excluded 1-7. The 1. of January is Monday.
So the theory was, you take a number divide by 7 and subtract the first number, so leaving only number after decimal point. Then multiply by 7 and you get number from 0 to 6 and it reflects the day name.
Yep, modulus is definitely the way to go here. lastchance's code is very nice. But just for your knowledge, you can avoid working with decimal (floating point) numbers by doing a - b * floor(a / b), which is equivalent to a - b * (a / b) if a and b are integers (integer division is floor division for n >= 0).
1 2 3 4 5 6 7 8 9 10
// you should use %
// this is to just show what it's mathematically equivalent to, for positive numbers
int a = 43;
int b = 7;
std::cout << a % b << std::endl;
std::cout << a - b * (a / b) << std::endl;