/* 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
#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
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.
ReplyDeleteyes 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/
DeleteAttention everyone, the file provided above is not working. I have been looking for the working file and finally found it.
ReplyDelete✔️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