Home > Back-end >  ?? There will be someone there?
?? There will be someone there?

Time:10-02

Program, input from the keyboard to a floating point number is not equal to zero, then the output of the floating point number symbols, respectively, the integer part and decimal part, such as input - 123.456, the output should be (in the following format output, need the same!!! ) :



Input format:

Floating-point



The output format:

Sign: - or +

Integral part:

A decimal fraction part: to 3 decimal places

There will be someone there?

CodePudding user response:

#include
using namespace std;

Int main ()
{
Float a;
cin> a;
Char s;

if(a> 0)
S='+'.
The else
{
S='-';
A=- a;
}
//two lines under the compiler will give you the warning of "may lose data", no need to worry, if really don't want to see a warning and a strong turn (int)
Int I=a;
Int d=1000 * (a - I);

Cout & lt; <"The sign:" & lt; Cout & lt; <"Integral part:" & lt; Cout & lt; <"A decimal fraction part:" & lt; system("pause");
return 0;
}
  • Related