Hi
I'm trying to write a program that will print the results of the series
sqrt(1), sqrt(1)+sqrt(2), sqrt(1)+sqrt(2)+sqrt(3),...., sqrt(1)+sqrt(2)+sqrt(3)+...+sqrt(n)
where n is chosen by the user. The output should look something like
1, 2.414, 4.146, 6.146, 8.382, 10.831, .....
Here's what I have so far
#include <iostream>
#include <cmath>
using namespace std;
void sumN();
double count;
int Q;
int i;
int main() {
cin>>Q;
for (i=1;i<=Q;i++)
cout<<sumN(i)<<" ";
}
void sumN()
{
for(int i=0;i<=Q;i++){
sumN(i)+=sqrt(i);}
}
Any help would be appreciated
Thanks