+ 3

Can some explain that how this program works

#include <iostream> using namespace std; int main(){ double num;double mod=1;double c=0; cout <<"Enter a number "; cin>>num; for(int d=0; d<50; d++){ if(c*c>num){ c-=mod; mod/=10;} c+=mod; } cout<<"Square root of "<<num <<" is "<<c<<endl; return 0; }

2nd Apr 2019, 6:32 AM
Varun
1 Réponse
+ 1
It iterates 50 times to approximate the square root of the user input.
3rd Apr 2019, 8:28 PM
::sк::
::sк:: - avatar