I am new in C language and I am trying to make a program that is able to take a decimal number and print out the closest number to that decimal, However, when I try to run the program it only asks me for the decimal number and nothing else.
# include<stdio.h>
int main()
{
float num;
printf("Enter a double number: ");
scanf("%d", num);
int r=0;
if(num<0)
{
r=r+num-0.5;
}
else
{
r=r+num+0.5;
}
printf("The closest integer to %d: %d", num, r);
return 0;
}
If you could help me find the issue with my program I would be very thankful. Thank you!