Why does it trigger twice when ive only inputed 2, 3 and Y? (Relatively new to c again) | Sololearn: Learn to code for FREE!

+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

9/29/2020 9:59:44 AM

Marc Stephen Gabres

2 Answers

New Answer

+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..

0

Thanks a lot for your help.