How to add new line in c

In C, you can add a new line to the output using the \n character. This is called a newline character.

Here are a few ways to add a new line in C:

  1. Using printf:

    printf("Hello, world!\n");

    The \n at the end of the string will print a new line.

  2. Using puts:

    puts("Hello, world!");

    The puts function automatically adds a new line at the end of the string.

  3. Using fprintf:

    fprintf(stdout, "Hello, world!\n");

    This is similar to printf, but fprintf allows you to specify the output stream (in this case, stdout).

  4. Using write:

    write(1, "Hello, world!\n", 13);

    This is a more low-level way to add a new line, using the write system call to write to the standard output (file descriptor 1).

Note that the \n character is not actually a character in the classical sense, but rather a special sequence of characters that tells the terminal to move to the next line. This is why it's often referred to as a "newline" character.