What Value Returned By Scanf Function In C Language ?

Prashant | Sun, 14 Jun, 2020 | 170

Value returned by scanf function in C language

In this tutorial we will learn what value is returnd by a scanf function ?

scanf() in C language

This is a library function of stdio.h, it is used to read value from the standard input device (keyboard).

The thing that we are going to discuss here is its return type.

Return type of scanf()

scanf() returns total number of inputs. For example, if you are taking 3 inputs through single scanf(), scanf() will return 3.

Consider the program:

#include <stdio.h>

int main()
{
    int a,b;
    int result;
    
    printf("Enter two number: ");
    result=scanf("%d%d",&a,&b);
    printf("Total inputs: %d\n",result);
    
    return 0;
}

Output

Enter two number: 10 20
Total inputs: 2

n this program, we entered two values 10 and 20. Thus, there are two inputs and the output is "Total inputs: 2".

"This is very basic program written by me (I started learning C programming language few weeks ago). I found this topic very useful to share. If you liked, please leave your comment...".

 

 

 

 

 

 

 

Related Articles :- 

1Introduction And Getting Started With C

2Basic Of C Language

3. Why We Should Use C Language

4. Applications Of C Programming

5. Basic Rules For Writting C Program

6. Keywords In C Language

7. Comments In C Programming

8. Tokens In C

9. Difference Between Int Main And Void Main

10. C Processor And Macros

11. Variables In C

12. Types Of Variables In C

13. Difference Between Local And Global Variable

14. Difference Bwtween Auto / Extern / Static Variable

15. Constant In C

16. How To Access Global Variable Using Extern Keyword In C

17. Exit And Return Staterment In C

18. Print Float Value Upto N Decimals In C Programming

19. How To Print Multiline Message Using Single Printf In C Programming ?

20. What Value Returned By Scanf Function In C Language ?

21. What Value Is Returned By Printf And Scanf In C

22. What Do 'Lvalue' And 'Rvalue' Mean In C/C++?

23. Errors In C Programming ?

0 comments
Leave a comment