Pages

This blog is under construction

Thursday, December 20, 2018

C program that reads a floating-point number and then displays the right –most digit of the integral part & left-most digit of fractional part of the number.

#include<stdio.h>
void main()
{
float x,y;
int z,w;
printf("Enter floating point number : x= ");
scanf("%f",&x);
z=(int)x%10;
y=x-(int)x;
w=(int)(y*10);
printf(" \nThe Right-most digit of the integral part of the number %.2f is %d",x,z);
printf(" \nThe Left-most digit of the fractional part of the number %.2f is %d",x,w);
   
}

Enter floating point number : x= 123.75                                                                                                              
                                                                                                                                                     
The Right-most digit of the integral part of the number 123.75 is 3                                                                                 
The Left-most digit of the fractional part of the number 123.75 is 7   

No comments:

Post a Comment