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