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