int a;
printf("%d", scanf("%d",&a));
what would be the output of this code snippet??
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Sep 4, 2013, 5:38 PM
If you type an integer (or something which begins with an integer), then scanf will successfully match it and return 1 which will therefore be printed to the console.
However, if you type something which isn't an integer (say abc), then scanf will be unable to match it and will return 0 which will then be printed to the console.