What values do the printf() and scanf() functions return ?
printf() : It returns total number of Characters Printed, Or negative value if an output error or an encoding error
Example 1: The printf() function in the code written below returns 6. As ‘CODING’ contains 6 characters.
While printing CODING, the value returned by printf() is : 6
Example 2: The printf() function in the code written below returns 9. As ‘123456789’ contains 9 characters.
While printing 123456789, the value returned by printf() is : 9
scanf() : It returns total number of Inputs Scanned successfully, or EOF if input failure occurs before the first receiving argument was assigned.
Example 1: The first scanf() function in the code written below returns 1, as it is scanning 1 item. Similarly second scanf() returns 2 as it is scanning 2 inputs and third scanf() returns 3 as it is scanning 3 inputs.
Input: Hey! welcome to geeks for geeks Output: First scanf() returns : 1 Second scanf() returns : 2 Third scanf() returns : 3