A simple program about displaying number
Hello everyone!
This is my first post here...sorry if someone already started a thread before..i couldnt find one related to this...
okay..i want to write a simple program that gets a floating point number from the user and display only the right most digit that is before the decimal point...
i have tried out one and found working too...
what i need to know is that..is there any other way to do this....a simple way ofcourse..
Here is my code...
Code:
#include<stdio.h>
void main()
{
float x;
int i,temp,check;
clrscr();
printf("Enter a real number:");
scanf("%f",&x);
temp=x;
for(i=0;i<=9;i++)
{
check=temp+i;
if(check%10==0)
break;
else
check=check-i;
}
i=10-i;
printf("\n %d",i);
getch();
}
Thanks in advance for your inputs :)
btw i use win xp and turbo c version 3.0 from borland...