C, C++, Java and C# run on the CodeLab runner: the program asks for its input while it runs, as in a terminal. The example has a default input that readers start from.
#include <stdio.h>
int main(void)
{
int x, n = 0, sum = 0;
while (scanf("%d", &x) == 1) {
sum += x;
n++;
}
printf("Numbers: %d, sum: %d\n", n, sum);
return 0;
}
4 8 15 16 23
Student
- Click Run: the numbers of the field Input are sent first. Type more numbers in the console, each followed by Enter.
- The program reads to the end of the input: click End of input (Ctrl+D).
- Stop ends a program that does not end, for example an endless loop. On a phone the check button sends the line.
Teacher
- In the dialog the field Input is saved with the example as its default input.
- JavaScript, Pascal and PHP run on Jobe: there the whole input is given before the run.