fork download
  1. #include <iostream>
  2. using namespace std;
  3. #include <stdio.h>
  4. int main () {
  5. /* variable definition: */
  6. int count, value, sum;
  7. /* Initialize */
  8. count = 0;
  9. value = 0;
  10. sum = 0.0;
  11. // Loop through to input values
  12. while (count < 5)
  13. {
  14. printf("Enter a positive Integer\n");
  15. scanf("%d", &value);
  16. if (value >= 0)
  17. {
  18. sum = count * value;
  19. }
  20. else {
  21. printf("Value must be positive\n");
  22. }
  23. count++;
  24. // Calculate sum. Need to type cast since two integers will yield an integer sum = (double) sum*count;
  25. printf("sum is %lf\n " , value );
  26. return 0;
  27. }
  28.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
1
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:27:1: error: expected ‘}’ at end of input
 }
 ^
stdout
Standard output is empty