0
what is the problem?
#include <iostream> using namespace std; int main() { float x; int y; cin >> x; y=x; cout <<y<<endl; x=x-y; for(; ;){ x=x*10; y=x; if(y==x) break; } cout << x; return 0; }
1 Réponse
+ 1
Here, I modified your code a bit, hope this helps.
#include <iostream>
int main()
{
float x;
int y;
std::cin >> x;
std::cout << "float: " << x;
y = static_cast<int>(x);
x -= y;
std::cout << "\nfloat: " << x << "\nint: " << y;
return 0;
}