Can anyone explain why the integer is not printing? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can anyone explain why the integer is not printing?

https://code.sololearn.com/c1AOZqe2Huaa/?ref=app

6th Oct 2023, 12:06 PM
Vaibhav Chauhan
Vaibhav Chauhan - avatar
3 Answers
+ 2
You could cast the float to an int ("cut off decimal part"): printf(..., (int)ab);
6th Oct 2023, 12:37 PM
Lisa
Lisa - avatar
+ 2
There are several issues with your code: 1. Remove conio.h and getch(). conio is compiler specific, outdated and unnecessary. So is its function getch(). 2. The main method in c is of type int, not void. It should return an integer. 3. ab is a float, not an int. hence you need to print it with %f, not %d.
6th Oct 2023, 12:22 PM
Lisa
Lisa - avatar
+ 1
I got it, I know that it's a float type but I want to print only '45' How can I do that?
6th Oct 2023, 12:35 PM
Vaibhav Chauhan
Vaibhav Chauhan - avatar