Â
In this, we are going to  find square root of a number with the help of C++ program.
The Code given below can be used in Turbo C++ Compiler.
// Square root of a number #include<iostream.h> #include<conio.h> #include <math.h> // this is necessary for power, sqrt etc... void main() { clrscr(); int perfectSquare = 16; int nonPerfectSquare = 10; int c = sqrt(perfectSquare); float d = sqrt(nonPerfectSquare); cout<<"Sqrt of "<<perfectSquare<<" : "<<c<<endl; cout<<"Sqrt of "<<nonPerfectSquare<<" : "<<d<<endl; getch(); }
// Square root of a number
#include <iostream>
#include <math.h>
// this is necessary for power, sqrt etc...
using namespace std;
int main()
{
int perfectSquare = 16;
int nonPerfectSquare = 10;
int c = sqrt(perfectSquare);
float d = sqrt(nonPerfectSquare);
cout<<"Sqrt of "<<perfectSquare<<" : "<<c<<endl;
cout<<"Sqrt of "<<nonPerfectSquare<<" : "<<d<<endl;
return 0;
}
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP