Re: help solving addition problem in C



On Oct 14, 11:39 am, Pranav <pranav...@xxxxxxxxx> wrote:
On Oct 14, 11:30 am, "@$|-|. DUBEY" <dubey.ashw...@xxxxxxxxx> wrote:

i have a interger
val = 99999;
and i want to add the content of val i.e., 9+9+9+9+9 = 45;

how to do that....
need urgent help

take a temporary variable to store sum and initialize it to zero,
Now by recursively taking modulus and dividing the number you can each
digit separated and you can go on adding the digit..,



can u explain with code...
i didn't understand.....
.



Relevant Pages

  • Re: help solving addition problem in C
    ... take a temporary variable to store sum and initialize it to zero, ... Now by recursively taking modulus and dividing the number you can each ...
    (comp.lang.c)
  • Re: Problem only in release version!
    ... not executed in Release mode (I believe, but I also thought Debug ... initialized variables to zero, ... The Release version will not initialize anything 'naturally' ... >>the contents of the memory addresses they happen to get assigned to). ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Problem only in release version!
    ... The debug version doesn't initialize anything to zero that isn't ... the debug heap manager sets memory to certain non-zero values ...
    (microsoft.public.dotnet.languages.vc)
  • Re: [crash, bisected] Re: [PATCH 3/4] x86_64: Fold pda into per cpu area
    ... to initialize the kernel segments. ... The zero-based PDA mechanism requires the introduction of a new ELF ... Why are we doing a zero based pda? ... offset in the segment register to allow for everything to work as ...
    (Linux-Kernel)
  • Re: Storage of Variables
    ... code at entry to a function zero out the stack. ... In C, there is really no such concept as a heap, though you could ... the bss segment. ... And to initialize the data segment, ...
    (comp.os.linux.misc)