#include <stdio.h>
int main() {
printf("First line\n");
printf("Second line\n");
printf("Third line\n");
return 0;
}
Output:
arduino
Copy code
First line
Second line
Third line
👉 Explanation:
"First line\n" → prints First line then moves to the next line.
"Second line\n" → prints Second line then moves to the next line.
"Third line\n" → prints Third line then moves to the next line.
So every time you put \n at the end, the cursor moves down one line after printing the text.
-----------------------------------------------------------------------------------------------------------------------------
📌 Example 1: \n at the end
Output:
👉 Here \n moves the cursor to the next line after the text.
📌 Example 2: \n at the beginning
Output:
👉 Because \n is written before the text, the cursor first jumps to a new line and then prints.
📌 Example 3: \n in the middle
Output:
👉 Here, \n splits the text into multiple lines wherever it appears in the middle.
✅ Summary:
-
\n= moves to a new line. -
At end → text prints then moves to next line.
-
At beginning → first moves to next line, then prints text.
-
In middle → splits the output into multiple lines.
No comments:
Post a Comment