C C++ Java Data Structure Python JavaScript CSS Ajax PL/SQL PHP Puzzles C programs C++ programs Java programs

Home » C programming language

Value returned by scanf function in C language

In this article, we are going to learn about scanf function, what does scanf returned in c programming language?
Submitted by Manju Tomar, on September 20, 2017

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: ");
    printf("Total inputs: %d\n",result);
    return 0;


Enter two number: 10 20
Total inputs: 2

In 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..."