Home > Back-end >  Why don't input negative result right?
Why don't input negative result right?

Time:09-18

#include
Void main ()
{
Int x, y;
Float business;
The scanf (" % d, % d ", & amp; X, & amp; Y);
Business=(x + y)/2.0;
Printf (" business=% 1 f \ n % d ", business);
}

CodePudding user response:

Printf (" business=% 1 f \ n % d ", business) here for more than % d
Runtime input - 20, 10
Want to have a comma between the two number,

CodePudding user response:

Still not correct, the output is the result of the 429496736.0,

CodePudding user response:

I know, input negative computer automatically changed to Chinese, "" so wrong

CodePudding user response:

Printf (" business=% 1 f \ n % d ", business);
There are two format control characters, why there is only one variable?
% d can enter a negative number, but should pay attention to what time
1. Beyond the range of int?
2. Whether completely according to the scanf wrote to enter? "% d, % d" said: do you want to input digital commas in English

CodePudding user response:

 printf (" business=% 1 f \ n ", business); 

To such, remove % d, because the business, and % d match
  • Related