C Program Inverse Series
/* Write a program to print 1+1/2+1/3+1/4+………+1/N series. */
#include <stdio.h>
int main(void) {
int n;
float sum=0;
printf("Enter Value of N : ");
scanf("%d",&n);
while(n>0)
{
sum = sum + (1.0/n);
n--;
}
printf(" Sum = %.2f",sum);
return 0;
}
#include <stdio.h>
int main(void) {
int n;
float sum=0;
printf("Enter Value of N : ");
scanf("%d",&n);
while(n>0)
{
sum = sum + (1.0/n);
n--;
}
printf(" Sum = %.2f",sum);
return 0;
}
Comments
Post a Comment