Respuesta :
Answer:
The code to this question can be defined as follows:
Code:
#include <stdio.h> //defining header file
int main() //defining main method
{
float user_num; //defining float variable
printf("Enter a value: "); //message
scanf("%f",&user_num); //input value from user end
printf("%f, ",user_num); //print value
while (user_num>1) //loop to calculte value
{
user_num=user_num/2; //diving value
printf("%f, ",user_num); //print value.
}
return 0;
}
Output:
Enter a value: 20
20.000000, 10.000000, 5.000000, 2.500000, 1.250000, 0.625000,
Explanation:
Description of the code as follows:
- First, a float variable "user_num" is declared, in which we take input from the user-end.
- In the next step, a while loop is declared, that uses the above variable to calculates its value.
- Inside the loop variable "user_num" divide its value by 2 and holds its calculated value, to print its value the "printf" method is used that prints its value.