Computer Science, asked by bhumikatiwari0466, 8 hours ago

Square Root (Integral) c++
Given a number N, find its square root. You need to find and print only the integral part of square root of N.
For eg. if number given is 18, answer is 4.

Answers

Answered by anindyaadhikari13
2

\texttt{\textsf{\large{\underline{Hint!}}}}

1. Accept the number.

2. Use sqrt() by including <cmath> header file.

3. Use type casting to convert double to int.

\texttt{\textsf{\large{\underline{The C{o}de!}}}}

#include <iostream>

#include <cmath>

using namespace std;

int main() {

   int n;

   cout<<"Enter a number: ";

   cin>>n;

   cout<<"Integral part of sqrt: "<<(int)(sqrt(n));

   return 0;

}

\texttt{\textsf{\large{\underline{Sample I/O!}}}}

Enter a number: 18

Integral part of sqrt: 4

See attachment for verification.

Attachments:
Similar questions