Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int i,n,sum=0;
- printf("enter 1 to 100 : ");
- scanf("%d",&n);
- printf("\nThe first %d natural numbers are:\n",n);
- for(i=1;i<=n;i++)
- {
- printf("%d ",i);
- sum+=i;
- }
- printf("\nThe Sum of natural numbers upto %d terms : %d \n",n,sum);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement