+ 3

Why does it trigger twice when ive only inputed 2, 3 and Y? (Relatively new to c again)

https://code.sololearn.com/c3mKD1uY7vCl/?ref=app

29th Sep 2020, 9:59 AM
Marc Stephen Gabres
Marc Stephen Gabres - avatar
2 Answers
+ 1
If input is 2 3 y Then After input to a, b by 2 3 a space is read by scanf("%c", &try) ; so now try has value as space charecter. So it is not equal to y or Y. And again until input console see the next required input of Integer for a, it won't read value and retain its privoius values.. Test by this input 2 3y Or put statement getchar() before scanf for consume space after 3 input..
29th Sep 2020, 10:24 AM
Jayakrishna 🇼🇳
0
Thanks a lot for your help.
29th Sep 2020, 10:33 AM
Marc Stephen Gabres
Marc Stephen Gabres - avatar