0
I'm going to print the sigma from n=30 , i=1 ( i²+1) so can you help me to find my mistake
#include <iostream> #include <cmath> using namespace std; int main(){ int n=0; int sum=0; int i=1; do{ cout<<"this program will calculate the sum of (i^2+1) , where i goes from 1 to n"<<endl; cout<<"Enter the value for n:"<<endl; cin>>n; for(i=1;i<=30;i++){ sum=sum+1; sum=pow(i,2)+1; } cout<<"the sum is "<<sum; }while(0); return 0; }
1 Respuesta
+ 1
You want find sigma (i^2+1), then why are you increasing sum by one....