C Programming - Strings - Discussion

Discussion Forum : Strings - General Questions (Q.No. 3)
3.
How will you print \n on the screen?
printf("\n");
echo "\\n";
printf('\n');
printf("\\n");
Answer: Option
Explanation:

The statement printf("\\n"); prints '\n' on the screen.

Discussion:
23 comments Page 1 of 3.

Praveen Negalurmath said:   6 years ago
If u put printf("\\n");

It could have printed \, why does it prints \n? Anyone explain.
(3)

Shashank said:   1 decade ago
Give me specific reason about this answer. Why there is "\\" is used ?
(1)

Vavilapalli sateesh said:   9 years ago
"\\n "means it gives the output to the user whereas in "\n"gives white space and leave some lines.
(1)

Karthik saakre said:   1 decade ago
Actually, printf ("\n") : will skip a line leaving the current line.
(1)

Sunny said:   2 decades ago
Great. Really good one example.
(1)

Vinod said:   1 decade ago
This is verbatim string. Putting any special character after "\" sign ignoresthe next character for compilation.
(1)

Srilakshmi said:   1 decade ago
By using printf("\n"); we get blankscreen as \n is a white space character but printf("\\n"); gives output as \n
(1)

Venkatesh said:   10 years ago
\ is escape sequence escape after letter while compilation.

Priya said:   8 years ago
@Komal.

\\n is used for print\n
print("\\n")->it print \n
print("\\s")->it print \s
likewise it print.

Komal more said:   8 years ago
Why there is "\\" used?


Post your comments here:

Your comments will be displayed after verification.