Search C Program | nimishsoft@gmail.com

Sum of digits using for loop

/* Sum of digits using for loop */

#include<stdio.h>
int main()
{
    int a, s;
    printf("Enter value of a: ");
    scanf("%d",&a);
    for(s=0;a>0;a=a/10)
        s = s + (a%10);
    printf("Sum of digits: %d",s);
    return 0;
}

Related Post:
Sum of digits using while loop
http://cbasicprogram.blogspot.in/2012/02/sum-of-digits-using-while-loop.html 

3 comments:

  1. the programme is unable to understand about which variable stands for what.It is better to use (//.....)things like that to express the given variable.And the programme will be very effective and easier.

    ReplyDelete
    Replies
    1. yes it just a program without any description. if you are looking for step by step integration suggest you to check this website. https://interviewspreparation.com/sum-of-digits-program-in-c/

      Delete
  2. Attention everyone, the file provided above is not working. I have been looking for the working file and finally found it.



    ✔️Click Here To Download http://gestyy.com/e0GAyS
    ✔️Click Here To Download

    ✔️Click Here To Download http://exe.io/XONVsO6l

    ✔️Click Here To Download


    ✔️Click Here To Download
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .

    .

    .
    .

    .

    .
    .
    .
    .

    Mn.
    ..

    .
    .
    .
    ..
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    ..
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .zx
    .
    .sdcxzzxccxxx

    ReplyDelete