Question
Write a C++ program that: (a) declares a variable X for storing a floating point number and initializes it with zero. (b) asks the user
Write a C++ program that: (a) declares a variable X for storing a floating point number and initializes it with zero. (b) asks the user to input a floating point number with 6 digits : 3 digits in whole number part and 3 digits in decimal part. (c) read user-input value and store it in X. (d) print digits in different positions of the X (hundreds, tens, ones, tenths, hundredths and thousandths) in the format shown in the sample output. Use tabs and newlines to mimic the format. (e) round user-input value stored in X and store the result it in X. (f) print out the rounded value. (Please do not use loops, the program should be as simple as possible.)
Sample Output
Input a floating-point number with 6 digits (3 in whole number part and 3 in decimal part i.e. XXX.XXX) 456.789
The decimal part:
thousandths: 9
hundredths: 8
tenths: 7
The whole number part:
ones : 6
tens : 5
hundreds : 4
Rounded value : 457
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started