0
Write a program that prints the integer part and float part of any float number
13 odpowiedzi
+ 9
Shayma Khader
main () {
Float x ;
Cout << " write any decimal number: " <<endl;
Cin>> x ;
cout<<int(x); //Explicitly converting float to int
cout<<x-int(x); //Gives Float part....
Thats it...
CHERIEF Houcine Abdelkader has directly given an eg code ...
+ 7
Hii Shayma Khader
The attempt which you have putted in "answer" it would be great if you can edit your question and can put it in description for getting best results!
If you have already received your answer then "try to do these things from next time"
Have a great day!
Hope you understand 👍
+ 4
Show ur attempt first , then we will help with that..
+ 2
Alphin K Sajan thank you ♥️♥️♥️♥️♥️♥️
+ 2
Shayma Khader Wlcm (⊜‿⊜✴)
+ 1
main () {
Float x ;
Cout << " write any decimal number: " <<endl;
Cin>> x ;
Here i dont know what I do seriously
+ 1
Alphin K Sajan help me now please
+ 1
CHERIEF Houcine Abdelkader thank you put i need a semple answering because we didn't learn any thing about (for ) yet
+ 1
If you were not restricted by requirements to make your own implementation, then you can use std::modf() defined in <cmath> header.
#include <iostream>
#include <cmath> // modf
using namespace std;
int main()
{
float n {12.35};
float integral_part, decimal_part;
decimal_part = modf( n, &integral_part );
cout << integral_part << " + " << decimal_part << "\n";
// http://www.cplusplus.com/reference/cmath/modf/
return 0;
}
0
Ok i well show how i think about the solution
0
Hi