Q. What will be the output of this code?

Code:
void main()
{
      int i;
      printf("%d", scanf("%d", &i)); // value 10 is given as input here
}
  • (A) 10
  • (B) 1
  • (C) Garbage value
  • (D) None of these
πŸ’¬ Discuss
βœ… Correct Answer: (B) 1
Explanation: scanf returns number of items successfully read and not 1/0. Here 10 is given as input which should have been scanned successfully. So number of items read is 1.
Explanation by: Rajeev Malhotra
scanf returns number of items successfully read and not 1/0. Here 10 is given as input which should have been scanned successfully. So number of items read is 1.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
180
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Rajeev Malhotra
Publisher
πŸ“ˆ
95%
Success Rate