Returned values of Printf, Scanf and other functions in C

05 min read

printf() - printf() returns the number of characters successfully written on the output. It is used to simply print data in the output.

scanf() - It returns the number of data items that have been entered successfully. It is used to read input data (simile characters, numerical values, and strings) entered into the computer from a standard input device.

getchar() -Reads a character from the standard input device. The return type of this function is int.

putchar() - Sends a character to the standard output device.

getc(): It reads a single character from a given input stream and returns the corresponding integer value

Example:

int main()
{
  printf(" %d", printf("%s", "this is codelab"));
  getchar();


 
int main()
{
  char a[50]; 
  printf(" %d", scanf("%s", a));
  getchar();
POST A NEW COMMENT
     
  • Input (stdin)

    Output (stdout)


    Input (stdin)

    Your Output (stdout)

    Expected Output

    Compiler Message

    Input (stdin)

    2    3

    Your Output (stdout)

    5

    Expected Output

    5

    Compiler Message

    5

    Error