aboutsummaryrefslogtreecommitdiff
path: root/rcc-legacy/tests/functional/21_suminput.sy
blob: 15bfb974d0dba258888d71e0a8c7842c91961023 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//sample:input n numbers,then print the sum of them;
int n;
int a[10];
int main()
{
	n = getint();
	if (n > 10) 
		return 1;
	int s;
	int i;
	i = 0;
	s = i;
	while (i < n) { 
	  a[i] = getint();
	  s = s + a[i]; 
	  i=i+1;
	} 
	putint(s);
	int newline;
	newline = 10;
	putch(newline);
	return s;
}