int a;
printf("%d", scanf("%d",&a));
what would be the output of this code snippet??
Output of this c program
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Sep 4, 2013, 1:38 PM EDT
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.