Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // C Program to Calculate the Sum of Natural Numbers
- #include<stdio.h>
- int main(){
- int sum=0,i,n;
- printf("Enter Integer Value :");
- scanf("%d",&n);
- for(i=1;i<=n;i++){
- sum+=i;
- }
- printf("Sum of first %d number is %d\n",n,sum);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment