+ 1

What is wrong in this code?

https://code.sololearn.com/ccBmJPz8hPO5/?ref=app With the inputs 3, 3 and R, the outputs is supposed to be 1.00 and 4.00. But it is 1.00 and 1.00, and in run.codes, apparently the outputs produced are 10.00 and 13.00.

13th Apr 2019, 8:04 PM
Mariana Ferreira
2 Respuestas
+ 5
On line 11 it should be "%c" instead of "%s", because you declared the variable char type. Also add an interval => " %c". You can see it in the code. https://code.sololearn.com/c0RP9Av2iVXK/?ref=app
13th Apr 2019, 8:47 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 5
Change line 9 from this: scanf("%s", &sit); Into this: scanf(" %c", &sit); Explanation: The %s is used for string, you only read one char, so use %c. Notice there's a space before the %c, it was deliberate, to consume the line feed left behind from previous input. Without the space, variable <sit> is not correctly read. Hth, cmiiw
13th Apr 2019, 8:52 PM
Ipang