Search
 
SCRIPT & CODE EXAMPLE
 

CPP

Finding square root without using sqrt function?

// Online C++ compiler to run C++ program online
#include <iostream>
using namespace std;
double SqrtNumber (double num){
double temp = 0; 
double sqrt=num/2; 
while(sqrt!=temp) 
{ 
temp=sqrt; 
sqrt=(num/sqrt+sqrt)/2; 
}
}
int main() {
  cout <<SqrtNumber(4);

    return 0;
}
Comment

Finding square root without using sqrt function?

#include<iostream>
using namespace std;
double SqrtNumber (double num){
    if(num<=0){
    return 0;
    }
    int counter = ceil(num/2);
for(int i=2;i<=counter;i++){
if(i*i == num){
return i;
}
}
return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ read matttrix from text file 
Cpp :: constructor syntax in c++ 
Cpp :: why do we use pointers in c++ 
Cpp :: overload subscript operator cpp 
Cpp :: c++ inheritance constructor 
Cpp :: how to grab each character from a string 
Cpp :: print in c ++ 
Cpp :: CRED Coins codechef solution in c++ 
Cpp :: print hola mundo 
Cpp :: opencv cpp create single color image 
Cpp :: text color c++ 
Cpp :: c++ remove all elements equal to 
Cpp :: Initialize Vector Iterator 
Cpp :: if argv == string 
Cpp :: what is function c++ 
Cpp :: sliding window c++ 
Cpp :: input c++ 
Cpp :: c++ stl vector get iterator from index 
Cpp :: c++ catch Unhandled exception 
Cpp :: swap alternate elements in an array c++ problem 
Cpp :: erase range vector c++ 
Cpp :: sum of n natural numbers 
Cpp :: cpp custom exception 
Cpp :: nth fibonacci number 
Cpp :: min heap 
Cpp :: cpp compare strings 
Cpp :: cpp algorithm iota 
Cpp :: c++ calling variable constructor 
Cpp :: how to read rotary encoder c++ 
Cpp :: right rotation of array in c++ by one element 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =