C Programming - Control Instructions - Discussion

Discussion Forum : Control Instructions - True / False Questions (Q.No. 2)
2.
If scanf() is used to store a value in a char variable then along with the value a carriage return(\r) also gets stored it.
True
False
Answer: Option
Explanation:

No, the carriage return tells the compiler to read the input from the buffer after ENTER key is pressed.

Discussion:
10 comments Page 1 of 1.

Ajay said:   1 decade ago
What is carriage return?can someone please explain.

Muskaan said:   1 decade ago
Carriage return is '\r'.

It puts the cursor to the beginning of the line *while run time*.

Divya said:   1 decade ago
Ex:

printf("abc");
printf("\rde");

Then output is: dec.

Suraj said:   10 years ago
If it puts the cursor at the beginning of line then how output comes "dec"?

Suraj said:   10 years ago
Where is ab?

Rishabh said:   9 years ago
First printf statement executes the abc when the second printf execute the first carriage return will place the cursor at the beginning of line then abc will be overridden with dec.

Rishi said:   9 years ago
abc is override by the dec because \r return the cursor to beginning of the line.

Shital said:   9 years ago
Thanks. I totally understand about carriage return.

Srikanth said:   8 years ago
Anyone give any example program for the above question?

Prashant bhosale said:   5 years ago
What is the meaning of /r?

Post your comments here:

Your comments will be displayed after verification.