Hi Nikhil,

I think this piece of code might be closer to what you are thinking :)

#include<stdio.h>

int main() {
        int i=0;
        int length=0, sum=0;
        char the_string[200];
        int the_array[200];
        //memset(the_string, 0x0, 200*sizeof(char));
        scanf("%s", the_string);
        while(the_string[i]!='\0') {
                i++;
        }
        length = i;
        for(i=0; i<length; i++) {
                the_array[i] = the_string[i] - 0x30;
        }
        /* Now the_array contains the numbers inside the_string */
        for(i=0; i<length; i++) {
                sum += the_array[i];
        }
        printf("%d\n", sum);
        return 0;
}

Regards,
Vikram

On Wed, Dec 21, 2011 at 10:00 AM, Amir Hossein Sharifzadeh <
[email protected]> wrote:

> I believe that's impossible.
>
>
>
> On Wed, Dec 21, 2011 at 3:34 AM, Nikhil <[email protected]>wrote:
>
>> ok
>> using loop but without using any predifine functioin. What would be
>> the best answer of the problem???
>>
>> On Dec 19, 7:00 am, Vikram Gaur <[email protected]> wrote:
>> > hmm... by using lambda functions and map() in python, we can find the
>> > sum without actually using a loop.
>> >
>> > Here's my code:
>> >
>> > #!/usr/bin/python
>> > def f(item): return int(item);
>> >
>> > print sum(map(f,list(raw_input().strip())))
>> >
>> > On 12/19/11, Bruno Oliveira <[email protected]> wrote:
>> >
>> > > I think it can be done via functional programming and by using lambda
>> > > functions and lists by comprehension
>> >
>> > > --
>> > > You received this message because you are subscribed to the Google
>> Groups
>> > > "Google Code Jam" group.
>> > > To post to this group, send email to [email protected].
>> > > To unsubscribe from this group, send email to
>> > > [email protected].
>> > > For more options, visit this group at
>> > >http://groups.google.com/group/google-code?hl=en.
>> >
>> > --
>> > Thanks and Regards
>> > Vikram Gaur
>> > Software Engineer
>> > Samsung Engineering Labs, Noida
>> > +91-9818540102
>> >
>> > "Since human beings themselves are not fully debugged yet, there will be
>> > bugs in your code no matter what you do." - Chris Mason
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Code Jam" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/google-code?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-code?hl=en.
>



-- 
Thanks and Regards
Vikram Gaur
Software Engineer
Samsung Engineering Labs, Noida
+91-9818540102

"Since human beings themselves are not fully debugged yet, there will be
bugs in your code no matter what you do." - Chris Mason

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en.

Reply via email to