Skip to content

Instantly share code, notes, and snippets.

@echo-akash
Created August 10, 2017 17:08
Show Gist options
  • Save echo-akash/68387468ce0a6c3d30fb9c5b7e29b6bb to your computer and use it in GitHub Desktop.
Save echo-akash/68387468ce0a6c3d30fb9c5b7e29b6bb to your computer and use it in GitHub Desktop.
Print the sum of the series: 1+1/3+1/5+...+1/N=?
#include<stdio.h>
int main()
{
double n,sum=0,i;
printf("Please Give The Value of N: ");
scanf("%lf",&n);
for(i=1;i<=n;i=i+2)
{
sum = sum + (1/i);
}
printf("sum=%.2lf",sum);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment