Addition of the every single digit of the number like 434= 4+3+4
// addition of the elements of number
#include<stdio.h>
int main()
{
int i,j,n,sum=0,remainder;
printf("enter the number which you want to print:\n");
scanf("%d",&n);
while(n!=0)
{
remainder =n%10;
sum=sum+remainder;
n=n/10;
}
printf("%d",sum);
}
Comments
Post a Comment