170k views
3 votes
Using a while loop, write a C++ program that, beginning from 1, computes and displays the square roots of the first 25 odd positive integers.

1 Answer

4 votes

Answer:

#include <iostream>

#include <cmath>

using namespace std;

int main()

{

int i = 1;

while (i <= 25)

{

cout << sqrt(i * 2 - 1) << endl;

i++;

}

return 0;

}

User Jeff Wooden
by
8.9k points