How can I change the result of scanf into other number? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can I change the result of scanf into other number?

Hi I'm studying C. If a score below 0.0 is entered by scanf, I want to make it to be forced to change to 0.0. How can I code this?

4th Jun 2020, 5:35 PM
Soryung Lee
1 Answer
+ 2
int main() { float var; float score=0; scanf("%f",&var); if(var<score){ var=score; printf("%1.1f",var); } return 0; }
4th Jun 2020, 5:52 PM
Abhay
Abhay - avatar