Q:

What is the output of printf("%d",scanf("ABC"));?

#include <stdio.h>

int main()
{

    printf("%d",scanf("ABC"));
    return 0;

}

When I tried running it gives output as -1. Should it not give out an error ideally?

A:

Here
printf("%d",scanf("ABC")); 

scanf() waits for user input and if user input is other than EOF(sending EOF indication by hitting CTRL+D on linux or CTRL+Z on windows) & an empty file, it returns zero. and that return value gets printed by printf(). 
As I highlighted below this scanf("ABC") return 0 even in the event of an early matching failure.
From the manual page of scanf()

RETURN VALUE
These  functions  return the number of input items successfully
  matched
         and assigned, which can be fewer than provided for, or even zero in the
         event of an early matching failure.
The  value EOF is returned if the end of input is reached before
  either
         the first successful conversion or a matching failure occurs.   EOF  is
         also returned if a read error occurs, in which case the error indicator
         for the stream (see ferror(3)) is set, and errno is  set  indicate  the
         error.

Should it not give out an error ideally? No,read the syntax of scanf(), it is
int scanf(const char *format, ...);

and it's first argument is of const char* type i.e scanf() expects 1st argument as of const char* and 1st argument provided is "ABC" which is of char* type though you should provide some format specifier like %s etc.
Also as mentioned in comments neither printf() nor scanf() functions are required to produce any error message when misused, abused, or otherwise used erroneously.  

