#include <math.h>
//get square root of a number "b"
int main(){
int a = 2; //declare number you want to take square root of
int sqrtNum = sqrt (a); //assign the sqrt value to a variable
cout << sqrtNum << endl;
return 0;
}
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int x = 625;
int result = sqrt(x);
cout << "Square root of " << x << " is " << result << endl;
return 0;
}
#include <iostream>
#include<math.h>
using namespace std;
int main(){
int num, result;
cout<<"Enter a number: ";
cin>>num;
result = sqrt(num);
cout<<"Square root = "<<result;
return 0;
}
Code Example |
---|
Cpp :: cpp string slice |
Cpp :: palindrome program in c++ |
Cpp :: swap elements array c++ |
Cpp :: deep copy c++ |
Cpp :: c++ double is nan |
Cpp :: sorting vector elements c++ |
Cpp :: reverse order binary tree in c++ |
Cpp :: initialize dynamic array c++ to 0 |
Cpp :: iterate through map c++ |
Cpp :: factorial loop c++ |
Cpp :: unique_ptr syntax |
Cpp :: c++ vector of class objects |
Cpp :: how to play sounds in c++ |
Cpp :: convert 2d array to 1d c++ |
Cpp :: convert characters to lowercase c++ |
Cpp :: best websites for programming |
Cpp :: sort vector c++ |
Cpp :: life the universe and everything solution c++ |
Cpp :: c++ float and double |
Cpp :: accumulate() in c++ |
Cpp :: cpp map insert |
Cpp :: strring length in c++ |
Cpp :: how to make a square root function in c++ without stl |
Cpp :: bfs to detect cycle in undirected graph |
Cpp :: preorder |
Cpp :: c++ Attribute Parser |
Cpp :: reference c++ |
Cpp :: c++ multiply char |
Cpp :: rethrow exception c++ |
Cpp :: move elements from vector to unordered_set |