Subscribe for more such posts..

Dear Reader...
I hope u are like my posts. If so then please don't forget to like , share and follow my blog for more such posts ,also feel free to write suggestions in the comment box given over here.

Thank you...

Search This Blog

Programme in C using Function that returns the sum of all the odd digits.


 #include <stdio.h>

int sneha(int n)
{ int sum = 0 ; while(n != 0) { int rem = n % 10 ; if(rem % 2 != 0) { sum = sum + rem ; } n = n / 10 ; } return sum ; } int main() { int num ; printf("Enter any positive number: "); scanf("%d" , &num); printf("All odd digits sum is: %d\n" , sneha(num)); }


No comments:

Post a Comment