fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int sum = 0, k,n,istrue=1 ;
  5. while(istrue){
  6. printf("input and integer : ");
  7. scanf("%d",&n);
  8. if(n==0) break;
  9. for(k=0; k<=n ; k++){
  10. sum +=k ;
  11. }
  12. printf("the sum from 1 to %d is %d \n",n,sum);
  13. istrue=0;
  14.  
  15. }
  16.  
  17.  
  18.  
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0s 5320KB
stdin
10
stdout
input and integer : the sum from 1 to 10 is 55