repo.or.cz
/
letusc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
move to repo.or.cz
[letusc.git]
/
ch1
/
exercises
/
ex9.c
blob
61d93162dfb1997d60c891fa7d04f9fbe2edc2c1
1
/*sum of first and last digit of a four digit number*/
2
3
#include<stdio.h>
4
5
int
main
()
6
{
7
int
num
;
8
int
sum
;
9
printf
(
"Enter the four digit number:"
);
10
scanf
(
"%d"
,&
num
);
11
12
sum
=
0
;
13
14
sum
=
sum
+ (
num
%
10
);
15
num
=
num
/
10
;
16
num
=
num
/
10
;
17
num
=
num
/
10
;
18
sum
=
sum
+(
num
%
10
);
19
20
printf
(
"The sum is %d
\n
"
,
sum
);
21
22
23
return
0
;
24
}