Q:

How adding a New line in print statement can change way of output? 

In a for loop, if i am adding new line then it is printing at each iteration, And if i am just giving comma, means i want to print count down in one line, then it is waiting for completion of for loop. 
Which part i am missing? 
Following code will print the latest count down after every iteration completed (because of '\n')
#include <stdio.h>

int main () {
    int x;
    for (x =0; x< 10; x++) {
        printf("%d\n", x);
        sleep(1);
    }
    printf("Fire!\n");
    return 1;
}

Following code will not print the latest count down, but will print when everything is done (may be because of ',')
#include <stdio.h>

int main () {
    int x;
    for (x =0; x< 10; x++) {
        printf("%d, ", x);
        sleep(1);
    }
    printf("Fire!\n");
    return 1;
}

A:

You can flush the stdout buffer explicitly:
for (x =0; x< 10; x++) {
    printf("%d, ", x);
    fflush(stdout);
    sleep(1);
}

