#include <iostream>
#include <math.h>
#include <ctype.h>
using namespace std;
int main()
{
int n=0,tot=0;
float sum = 0;
float average = 0;
float product = 1;
cout<<"Type an integer and press Enter:\n";
cin>>n;
/*
Your logic goes here
*/
for(int i=1;i<=n;i++){
cout<<sum<<endl;
sum= sum+(1/i);
product=product*1/i;
tot++;
}
cout<<"Sum, product and average of reciprocals are:\n";
cout<<sum<<endl;
cout<<product<<endl;
cout<<average<<sum/tot<<endl;
}
Anyone please tell me what I am doing wrong , my sum is always equal to one, i don't know why. I put cout and at each iteration it printout "1". My logic is right but there is some mistake which i can't find.