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