Floor and ceil using if then

how to run Floor and ceil program with if then?
i have make the program but i cann't result.
someone maybe help me,please
this is my program:

#include <stdio.h>
#include <math.h>

int main(void){
double n;
long int c,f;
scanf("%lf",&n);
if(n==trunc(n)){//pembulatan bilangan real n
n=trunc(n);
printf("%.lf %.lf\n",n,n);
}else if(c>0){//jika c positif maka floornya c itu sendiri dan ceillnya floor +1
c=trunc(n);
f=c+1;
printf("%ld %ld\n",c,f);
}else if(c<0){//jika c negatif maka floornya c-1 dan ceilnya c itu sendiri
c=trunc(n);
f=c-1;
printf("%ld %ld\n",f,c);
}




}

https://www.cplusplus.com/articles/jEywvCM9/

> else if(c>0)
What is the value of c at this point?

It looks to be uninitialised to me.
What is the program supposed to do?

1
2
3
if (n == trunc(n)) {     //pembulatan bilangan real n
    n = trunc(n);


If the condition n == trunc(n) is true, then why set n = trunc(n) as it is already equal that value?
thankyou salem c and seeplus,i got itand my code has been succesfull
Topic archived. No new replies allowed.