Advertisement
afrinahoque

The Sum of Natural Numbers

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