Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
mamihk
/
iag0582
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b7e31954
authored
Feb 07, 2017
by
Mario Mihkelson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
essa praxi essa yl
parent
e9aa324b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
progra 2/tunnitoo1.c
progra 2/tunnitoo1.c
0 → 100644
View file @
b7e31954
#include <stdio.h>
#include <stdlib.h>
#define LINE_LEN 100
int
main
(
void
)
{
char
line
[
LINE_LEN
];
int
sum
,
i
,
read_cnt
,
numbers
[
5
];
FILE
*
in
=
fopen
(
"input.txt"
,
"r"
);
if
(
in
==
NULL
)
{
fprintf
(
stderr
,
"Fili ei saa avada!
\n
"
);
exit
(
EXIT_FAILURE
);
}
while
((
fgets
(
line
,
LINE_LEN
,
in
))
!=
NULL
)
{
read_cnt
=
sscanf
(
line
,
"%d %d %d %d %d"
,
&
numbers
[
0
],
&
numbers
[
1
],
&
numbers
[
2
],
&
numbers
[
3
],
&
numbers
[
4
]
);
if
(
read_cnt
!=
5
)
for
(
sum
=
i
=
0
;
i
<
read_cnt
;
++
i
)
sum
+=
numbers
[
i
];
printf
(
"Sum of numbers was: %d
\n
"
,
sum
);
}
return
EXIT_SUCCESS
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment