Miti059

7.sum of natural numbers

Jun 7th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.23 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     int n, i,sum=0;
  6.  
  7.     printf("Enter value of n : ");
  8.     scanf("%d", &n);
  9.  
  10.     for(i = 1; i <= n; i++)
  11.     {
  12.  
  13.       sum=sum+i;
  14.     }
  15.  
  16.         printf("%d\n",sum);
  17. return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment