Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3.  
  4. main()
  5. {
  6. int n,i,sum=0;
  7. printf("Input: ");
  8. scanf("%d",&n);
  9.  
  10. for(i=1;i<=n;++i){
  11.  
  12. printf("%d ",i);
  13. sum+=i;
  14. }
  15.  
  16. printf("\nThe sum of natural numbers is: %d",sum);
  17.  
  18. getch();
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement