From: Alexandre P Francisco Date: Tue, 11 Mar 2014 19:02:17 +0000 (+0000) Subject: Adding ex6 X-Git-Url: http://web.ist.utl.pt/aplf/git/?a=commitdiff_plain;h=52f17a922f49e77fea4f88ed70948d66d6ade0c7;p=iaed.git Adding ex6 --- 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; +}