The below code show wrong result for 44 and 84.
So, I tried to change \t into space and the numbers were shown correctly as shown below.
Why just having tab in printf cause the number to be print incorrectly? I have tried to change 4 into 7 and 8 and the same problem occurred.
#include <stdio.h>
int main()
{
for (int count = 1; count <= 100 ; ++count)
{
if((count % 4) == 0 )
printf("%d\t", count);
}
return 0;
}
and
#include <stdio.h>
int main()
{
for (int count = 1; count <= 100 ; ++count)
{
if((count % 4) == 0 )
printf("%d ", count);
}
return 0;
}
答案 0 :(得分:2)
It is printing correctly, but because of the online compiler cutting off the first digit (for some reason) you are unable to see it. If you click the 3rd button above the output screen (which will copy the output) and paste it into notepad you will see that your output is correct.
答案 1 :(得分:1)
Indeed. It is the out steam that cuts off the first character of the next line