I am having problems with the while function on the C programming language. It runs too many times, Ignoring the end condition.
#include <stdio.h>
int main()
{
long long int lenX,lenY,cube,needX,needY,i,t = 0;
scanf("%lld%lld%lld", &lenX,&lenY,&cube);
while (needX <= lenX)
{
needX + cube;
i++;
}
while (needY <= lenY)
{
needY + cube;
t++;
}
printf("%lld\n",i*t);
return 0;
}
When inputting 6 6 4(the answer should be 4) the output ranges from -8519971516809424873 to 0.
I'm sorry if I missed something obvious. I'm new to the C programming language
EDIT: It doesn't care about the numbers
#include <stdio.h>
int main()
{
long long int lenX,lenY,cube,needX,needY;
scanf("%lld%lld%lld", &lenX,&lenY,&cube);
while (needX*cube <= lenX)
{
needX = 574973;
}
while (needY*cube <= lenY)
{
needY = 4057348;
}
printf("%lld %lld %lld\n",needX*needY,needX,needY);
return 0;
}
Still outputs:409600 100 4096