Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need this answered ASAP. Please only use the libraires seen below and only fil

ID: 3857519 • Letter: I

Question

I need this answered ASAP. Please only use the libraires seen below and only fill in the , "type your code here" part.

#include <iostream>

using namespace std;

/* Type your code here. */

int main()

{

int num;

cout << "Please enter a number between 2 and 1000: ";

cin >> num;

cout << num << endl;

if ((num < 1) || (num > 1000))

cout << "Please follow the directions!" << endl;

else {

int answer;

answer = intSqrRoot(num);

cout << "The integer square root of ";

cout << num;

cout << " is ";

cout << answer;

cout << ".";

cout << endl;

}

}

12.11 Problem 12.4 Ask the user for a number between 2 and 1000. Using a loop, calculate the integer square root by calculating the square of every number from 1 until the square of the number is more than the number entered. The previous number is the integer square root. You must write a function called intSqrRoot which calculates the answer and returns it to main. See the template given. Sample run: Please enter a number between 2 and 1000:16 [1] 1 2]13] The integer square root of 16 is 4 The numbers in the square brackets are intermediate values LAB 10/27 ACTIVITY 2.11.1: Problem 12.4

Explanation / Answer

#include <iostream>

using namespace std;

/* Type your code here. */

int intSqrRoot(int num)

{

int sq = 1;// square of count

int count = 1;// increment count every iteraion

cout << "[" << count << "]";// Print intermediate values

while (sq <= num) //until square of count is greater then num

{

count++;

sq = count * count;

if (sq < num)

cout << "[" << count << "]";// Print intermediate values

}

cout << " ";

return count - 1;// previous of final number

}

int main()

{

int num;

cout << "Please enter a number between 2 and 1000: ";

cin >> num;

cout << num << endl;

if ((num < 1) || (num > 1000))

cout << "Please follow the directions!" << endl;

else {

int answer;

answer = intSqrRoot(num);

cout << "The integer square root of ";

cout << num;

cout << " is ";

cout << answer;

cout << ".";

cout << endl;

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote