Computer Science, asked by raash24bmjg, 5 days ago

How do I write a program that reads a floating-point number and then displays the right most digit of the integral part of the number?​

Answers

Answered by KingKnowsEverything
0

Answer:

Explanation:

First convert the float into int using typecasting. Then using the modulus operator, you can print the last digit. If you want only one last digit, use x%10, If you want last 2 digits, use x%100 and so on. The modulus operator gives the remainder.

int main()  

{  

float num;  

int x;  

scanf("%f",&num);  

x=(int)num;  

printf("%d",x%10);  

return 0;  

}  

Hope this helps.

Answered by krishgaming8167
0

Answer:

First convert the float into int using typecasting. Then using the modulus operator, you can print the last digit. If you want only one last digit, use x%10, If you want last 2 digits, use x%100 and so on. The modulus operator gives the remainder

Similar questions