fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.  
  5. int n, i, sum= 0;
  6.  
  7. printf("Enter the last number of your series: ");
  8. scanf("%d", &n);
  9.  
  10. printf("1 + 2 + 3 + ..... + %d", &n);
  11.  
  12. for(i=1; i<=n; i++)
  13. {
  14. sum= sum +i;
  15. }
  16. printf("= %d",sum);
  17. }
  18.  
  19.  
Success #stdin #stdout 0s 5288KB
stdin
45
stdout
Enter the last number of your series: 1 + 2 + 3 + ..... + 1190881508= 1035