Advertisement
Divyansh_Chourey

sum of series

Mar 15th, 2024
557
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.24 KB | Source Code | 0 0
  1. #include<stdio.h>
  2.  
  3. int main(){
  4.     int n;
  5.     float sum=0;
  6.     printf("Enter the number: ");
  7.     scanf("%d", &n);
  8.     for(int i=1; i<=n; i=i+1){
  9.         sum = sum+(1.0/i);
  10.     }
  11.     printf("%f", sum);
  12.     return 0;
  13. }
  14. /*OUTPUT:
  15. Enter the number: 10
  16. 2.928968
  17. */
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement