I am writing a simple code to find the sum of the odd and even numbers till a given number.Please ignore my code if it does not get the right answers.The issue I am facing is that a simple printf changes the entire output of my code. Here is the code : 

```
#include <stdio.h>
int main()
{
int num,i,sum_e,sum_o;
printf("\nEnter the number\n");
scanf("%d",&num);
sum_e=0;
sum_o=0;
for (i=1;i<=num;i++)
    printf("\n value of remainder = %d",i); // printf causing the change
if (i%2==0)
    {
        sum_e+=i;
    }
    else 
    {
        sum_o+=i;
    }
printf("\nsum of all odd numbers till %d = %d\n",num,sum_o);
printf("\nsum of all even numbers till %d = %d\n",num,sum_e);
return 0;
}

```

When I remove the printf("value of remainder") this is the output :

> 
> Enter the number
>  3
> 
> 
> sum of all odd numbers till 3 = 4
> 
> 
> sum of all even numbers till 3 = 2
> 
> 
> 

When I add the printf("value of remainder") this is the output :

> 
> Enter the number 
> 
> 
> 3
> 
> 
> value of remainder = 1
> 
> 
> value of remainder = 2
> 
> 
> value of remainder = 3
> 
> 
> sum of all odd numbers till 3 = 0
> 
> 
> sum of all even numbers till 3 = 4
> 
> 
> 

My question is that how can a simple printf mess or massively change the output of the code . Please help . Thanks . PS Apologies in advance if the question was not formatted properly.