Advertisement
Hafizur

Calculate the Sum of Natural Numbers.

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