From 52f17a922f49e77fea4f88ed70948d66d6ade0c7 Mon Sep 17 00:00:00 2001 From: Alexandre P Francisco Date: Tue, 11 Mar 2014 19:02:17 +0000 Subject: [PATCH] Adding ex6 --- aula02/ex6.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 aula02/ex6.c diff --git a/aula02/ex6.c b/aula02/ex6.c new file mode 100644 index 0000000..17ac4ae --- /dev/null +++ b/aula02/ex6.c @@ -0,0 +1,20 @@ +#include + +int main() { + int n, dc = 0, ds = 0; + + do { + printf("NĂºmero positivo: "); + scanf("%d", &n); + } while (n <= 0); + + while (n != 0) { + ds += n%10; + n /= 10; + dc ++; + } + + printf("#dig: %d, sum: %d\n", dc, ds); + + return 0; +} -- 2.30.2