0

C ++ problem with numbers

I need to check are there floats that ends with .0 and convert them to integers. How can I do that? For example if a = 2.0, i need to find that float and turn it to integer -a = 2?

29th Mar 2024, 11:44 PM
Levon Avetisyan
Levon Avetisyan - avatar
4 Respuestas
+ 1
suppose you find the addition of 2 float no. and want to convert the final result in integers, You can simply write as result= int("what ever u want to convert") . May be I am wrong but u can try this
30th Mar 2024, 12:21 AM
Diksha Shukla
0
#include <iostream> using namespace std; int main() { Int x, y; int sum; cout << "type a number"; cin >> x; cout << "type another number"; cin >> y; sum = x + y; cout << "sum is " << sum endl; return 0; }
31st Mar 2024, 8:41 AM
Logout Kwaku
Logout Kwaku - avatar
0
Please what's wrong with the above code?
31st Mar 2024, 8:41 AM
Logout Kwaku
Logout Kwaku - avatar
0
What result u want through this code?Logout Kwaku
31st Mar 2024, 12:11 PM
Diksha Shukla