i am having trouble finding the sqrt roots for a number. my assignment is to Write a program that prompts the user for a positive number and prints out the square roots of all the numbers from 1 to the entered number.
the problem i have is that i can only find the sqrt of the number i inputted and not up to that number
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <iostream>
#include <cmath>
usingnamespace std;
int main() {
double x;
cout <<"Enter how many numbers you wish to process:";
cin >> x;
if (x <= 0)
cout <<"Error negative value was entered";
else
cout << ": " << sqrt(x) << endl;
return 0;
}
if i enter 4 i only get the sqrt of 4 and not the sqrts of 1,2,3 and 4
#include <iostream>
#include <cmath>
usingnamespace std;
int main() {
double x;
int i;
cout <<"Enter how many numbers you wish to process:";
cin >> x;
for(int i=1;i<=x;i++)
cout<< sqrt(x);
}
i did this know i am only getting the sqrt of 4 4 times? can someone correct my for loop please