Respuesta :
num = float(input("Enter a number: "))
num1 = int(num)
print(num - num1)
I hope this helps!
Following are the C++ program to calculate the decimal part:
Program Explanation:
- Defining the header file.
- Defining the main method.
- Inside the method, a float variable "num" is declared that inputs the value.
- In the next step, an integer variable "x" is declared that converts float value into an integer that holds the whole part number.
- In the next step, "num" is declared that removes the whole number part from the decimal value, and prints its value.
Program:
#include <iostream>//header file
using namespace std;
int main()//main method
{
float num;//defining a string variable
cout<<"Enter password: ";//print message
cin>>num;//input float value
int x=int(num);//defining integer variable that converts float value into integer that hold whole part number
num=num-x;//remove whole number part from the decimal value
cout<<num;//print decimal number
return 0;
}
Output:
Please find the attached file.
Learn more:
brainly.com/question/17554487
