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 2 of 3.

Sangami said:   8 years ago
'\n' is the backslash character constant. specifically, it is an escape sequence. Thus to print backslash character itself put backslash (\) before that character.

Saroj kumari said:   9 years ago
Really, good concept.

Jayasai said:   9 years ago
If we put "ffn" in printf it showing output as ffn. But in question, they asked to print "fn".

123 said:   10 years ago
Please explain the concept with an example.

Pradeepa said:   10 years ago
This was really a good concept & useful discussion, Thank you friends.

Anuja said:   10 years ago
\n changes the line. But we wanna print \n so we have to take one "\".

Datta said:   1 decade 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 ?


Post your comments here:

Your comments will be displayed after verification.