More Examples of printf and scanf Functions
For Complete YouTube Video: Click Here
In this class, we will understand More Examples of printf and scanf functions.
We have already discussed the concepts of pre-defined functions, functions, and input-output functions.
Table of Contents
More Examples of printf and scanf Functions
Example 1
The image below is example 1 on printf and scanf functions.
In the above example, the innermost scanf function will get executed first and return two as the output.
The return value of the scanf is the input for the printf and outputs 2.
Example 2
The image below is example 2 on printf and scanf functions.
In the above example, the innermost printf function will get executed first and return the number of characters 16 as the output.
The outer printf will print 16 as the output.
Example 3
The image below is example 3 on printf and scanf functions.
In the above example, the innermost scanf returns one as it returns the number of scanned elements.
The returned value is given as the input to the printf in which scanf is embedded.
The inner printf will return 19 as it has 19 characters in the literal string.
The outer printf will print the output as “num bytes printed = 19”.