0

Write a program that prints the integer part and float part of any float number

2nd Dec 2020, 2:08 PM
Shayma Khader
Shayma Khader - avatar
13 ответов
+ 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 ...
2nd Dec 2020, 2:23 PM
Alphin K Sajan
Alphin K Sajan - avatar
+ 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 👍
2nd Dec 2020, 2:49 PM
Piyush
Piyush - avatar
+ 4
Show ur attempt first , then we will help with that..
2nd Dec 2020, 2:09 PM
Alphin K Sajan
Alphin K Sajan - avatar
2nd Dec 2020, 2:19 PM
CHERIEF Houcine Abdelkader
CHERIEF Houcine Abdelkader - avatar
+ 2
Alphin K Sajan thank you ♥️♥️♥️♥️♥️♥️
2nd Dec 2020, 2:29 PM
Shayma Khader
Shayma Khader - avatar
+ 2
Shayma Khader Wlcm (⊜‿⊜✴)
2nd Dec 2020, 2:30 PM
Alphin K Sajan
Alphin K Sajan - avatar
+ 1
main () { Float x ; Cout << " write any decimal number: " <<endl; Cin>> x ; Here i dont know what I do seriously
2nd Dec 2020, 2:17 PM
Shayma Khader
Shayma Khader - avatar
+ 1
Alphin K Sajan help me now please
2nd Dec 2020, 2:18 PM
Shayma Khader
Shayma Khader - avatar
+ 1
CHERIEF Houcine Abdelkader thank you put i need a semple answering because we didn't learn any thing about (for ) yet
2nd Dec 2020, 2:22 PM
Shayma Khader
Shayma Khader - avatar
+ 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; }
4th Dec 2020, 2:11 PM
Ipang
0
Ok i well show how i think about the solution
2nd Dec 2020, 2:14 PM
Shayma Khader
Shayma Khader - avatar
0
Hi
5th Dec 2020, 1:28 AM
Bekas Gean
Bekas Gean - avatar