517,578 views
2 votes
2 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.

User Daveed
by
2.7k points

1 Answer

19 votes
19 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 Marat Zimnurov
by
2.6k points