#include<stdio.h>
#include<conio.h>
// function to add odd digits
int Add_odd(int n)
{
int r,sum=0;
while(n!=0)
{
r=n%10;
if(r%2!=0)
sum=sum+r;
n=n/10;
}
return sum;
}
//main function
int main()
{
int n;
printf("Enter any number\n");
scanf("%d",&n);
printf("Sum of all the odd digits is: %d",Add_odd(n));
getch();
return 0;
}
Enter any number
6592
Sum of all the odd digits is: 14
--------------------------------
Process exited after 14.01 seconds with return value 0
Press any key to continue . . .