C Programming - Strings - Discussion
Discussion Forum : Strings - General Questions (Q.No. 3)
3.
How will you print \n on the screen?
Answer: Option
Explanation:
The statement printf("\\n"); prints '\n' on the screen.
Discussion:
23 comments Page 2 of 3.
Venkatesh said:
9 years ago
\ is escape sequence escape after letter while compilation.
Datta said:
10 years ago
Please explain me that?
Apshana said:
1 decade ago
Why \ is used before \n?
Ugn said:
1 decade ago
The question is quite ambiguous - not clear whether a string or the character \n is wanted t print.
Suraj kumar said:
1 decade ago
Can anyone explain, how the statement. echo "\\n";. Works ?
Raj said:
1 decade ago
\n -> takes the control to the newline if we give printf("\n").
So if we add one more \ it loses the newline property.
printf("\\n") -> it will print \n
printf("\\b") -> it prints \b
So if we add one more \ it loses the newline property.
printf("\\n") -> it will print \n
printf("\\b") -> it prints \b
Sasi said:
1 decade ago
Never heard about "\\n" can anyone explain in detail?
Tina Jadhav said:
1 decade ago
Usually we use \n, never heard about"\\n". When we have to use this?
Karthik saakre said:
1 decade ago
Actually, printf ("\n") : will skip a line leaving the current line.
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
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers