Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help with this question. The answer that was provided for this 3 years ag

ID: 3929071 • Letter: P

Question

Please help with this question. The answer that was provided for this 3 years ago did not work. Thank you in advance!

Write a program that prompts the user for a value greater than 10 as an input (you should loop until the user enters a valid value) and finds the square root of that number and the square root of the result, and continues to find the square root of the result until we reach a number that is smaller than 1.01. The program should output how many times the square root operation was performed

Explanation / Answer

#include <stdio.h>
#include <math.h>
int main ()
{
double x;
int count = 0;
// get valid input
do{
        printf("Enter number:");
        scanf("%lf",&x);
}while(x<10);
// find sqrt till x > 1.01
while(x>1.01){
    x = sqrt(x);
    count++;
}
printf("Count:%d ",count);
return(0);
}

/*

compile using gcc -o -lm program.c

sample output

Enter number:16

Count:9   

*/