0

Write a program to find the integer square root of a given number.That is the largest integer whose square is less than or equal to the given number.

4
Contributors
5
Replies
27
Views
1 Year
Discussion Span
Last Post by mabdullah4
1

OK, I've written it. If you let me have your teacher's email address I can submit it for you to save you the bother of copy/pasting it yourself.

DaniWeb Member Rules (which you agreed to when you signed up) include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/community/rules

0

this is not my assignment .i am actually want to preparing for exams but this question is very tough for me and in previous year this question had been asked .SO this is very important question Please Help BROTHER!!!!

0

Use the sqrt function from the cmath library. That gives you a double as an answer. Assign it to an integer variable.

int x = sqrt(24); // x = 4
0

Just giving you the code isn't going to help your ability. Memorising answers to possible questions is no way to improve, it's just a dead-end. If you want to do better in the exams then improve your programming skills by trying to code this yourself. If you try, and get stuck, then come back here and someone will help.

0
//Hope this Helps

#include<iostream>
using namespace std;
int main()
{
    int i=1,y=0,x=1;
    int number=0;
    cout<<"Enter Number to Find Square Root ";
    cin>>number;

    for(i=1;i*i<=number;i=i+1)
    {
        y=i*i;

        x = (i+1) * (i+1);
        if(x>number)
        {
            break;
        }

    }
    cout<<"The Square of the Number is "<<i<<endl;
    system("pause");

}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.