fork download
  1. #include <stdio.h>
  2. #define TRUE 1
  3.  
  4. int sumSeries(int n)
  5. {
  6. return 5;
  7. }
  8.  
  9. int main()
  10. {
  11. int n;
  12.  
  13.  
  14. do
  15. {
  16. printf("Enter a positive integer: \n");
  17. scanf("%d", &n);
  18. } while (!(n>0 && n<10000));
  19.  
  20.  
  21. printf("The sum of the series 1+3+5+... upto %d terms is %d\n", n, sumSeries(n));
  22.  
  23. return TRUE;
  24.  
  25. }
  26.  
  27.  
Runtime error #stdin #stdout 0s 2160KB
stdin
5
stdout
Enter a positive integer: 
The sum of  the series 1+3+5+... upto  5 terms is 5