+ 1

What is the error?

Can somebody help me debug this code? https://code.sololearn.com/cgtfvlo6U5Aa/?ref=app

18th Apr 2020, 5:45 PM
Akash
Akash - avatar
5 Antworten
+ 6
When you were writing this statement: int num=scanf("%d",&num); It is necessary to give input which scanf wants. If we give input then it becomes true so it returns 1 to num. That's why it was giving 1 whatever you gave the number.
18th Apr 2020, 5:57 PM
...
+ 6
Rewrite line 10 in two lines as follows: int num; scanf("%d",&num);
18th Apr 2020, 5:49 PM
...
+ 4
Akash Sil you are welcome
18th Apr 2020, 6:05 PM
...
+ 1
Swapnil ok now it works, but can you tell me why it wasn't working earlier
18th Apr 2020, 5:51 PM
Akash
Akash - avatar
+ 1
Swapnil Thanks😊
18th Apr 2020, 6:04 PM
Akash
Akash - avatar