Tia is new to programming. She needs to write a program which will receive the input as a floating point number. She needs to print the decimal part of the floating point of the number. She has written a few lines of code. Can you fill up the rest.
Read the input as string. Use string operations on the input to derive the answer easily.
Answers
Answered by
3
Answer:
by autofill option in ms excal.
Answered by
7
Answer:
#include<iostream>
#include<string>
using namespace std;
int main()
{ float x,rem;
int y,a,b;
cin>>x;
if(x<0)
{
x=x*(-1);
y=x;
rem=x-y;
a=rem*1000;
cout<<"Floating part is : "<<a+1;
}
else{
y=x;
rem=x-y;
b=rem*1000;
cout<<"Floating part is : "<<b;
}
}
But 2 test cases are failing
Similar questions