+ 3
Not understanding logic !
https://code.sololearn.com/cs968l7G5v6V/?ref=app In this program, I want to know why when the years are same and m2 is less than m1 , y don't return -1. I mean m2<m1 So, 12 is added to M2 Then 1 is subtracted from y2 i.e. when y1= y2 (eg. Both are 2020), y2 becomes 2020 - 1 = 2019 Now, y = y2 - y1 => y = 2019 - 2020 = -1 This is my logic but the program is okay (works fine) https://overiq.com/c-examples/c-program-to-calculate-the-difference-of-two-dates-in-years-months-and-days/
1 Antwort
+ 1
It's always giving some junk no. On inputting same year so it does work fine