+ 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; }
1 Resposta
+ 1
It iterates 50 times to approximate the square root of the user input.