xref: /third_party/ltp/tools/sparse/sparse-src/validation/backend/sum.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/ltp/tools/sparse/sparse-src/validation/backend/
1f08c3bdfSopenharmony_ciint printf(const char * fmt, ...);
2f08c3bdfSopenharmony_ci
3f08c3bdfSopenharmony_cistatic int sum(int n)
4f08c3bdfSopenharmony_ci{
5f08c3bdfSopenharmony_ci	int i, result = 0;
6f08c3bdfSopenharmony_ci
7f08c3bdfSopenharmony_ci	for (i = 1; i <= n; ++i)
8f08c3bdfSopenharmony_ci		result += i;
9f08c3bdfSopenharmony_ci	return result;
10f08c3bdfSopenharmony_ci}
11f08c3bdfSopenharmony_ci
12f08c3bdfSopenharmony_ciint main(int argc, char **argv)
13f08c3bdfSopenharmony_ci{
14f08c3bdfSopenharmony_ci	printf("%d\n", sum(5));
15f08c3bdfSopenharmony_ci	printf("%d\n", sum(100));
16f08c3bdfSopenharmony_ci	return 0;
17f08c3bdfSopenharmony_ci}
18f08c3bdfSopenharmony_ci
19f08c3bdfSopenharmony_ci/*
20f08c3bdfSopenharmony_ci * check-name: sum from 1 to n
21f08c3bdfSopenharmony_ci * check-command: sparsei --no-jit $file
22f08c3bdfSopenharmony_ci *
23f08c3bdfSopenharmony_ci * check-output-start
24f08c3bdfSopenharmony_ci15
25f08c3bdfSopenharmony_ci5050
26f08c3bdfSopenharmony_ci * check-output-end
27f08c3bdfSopenharmony_ci */
28

Indexes created Thu Nov 07 10:32:03 CST 2024