C code to calculate product of even digits of a given number Code Steps: 1. First input the number 2. Now initialize a variable =1, that stores the multiplication 3. Now start a while loop until number = 0 4. Inside while loop just find out all the digits by finding the remainder & check it if it is divisible by 2 5. If the number is divisible by 2 then multiply that number with the variable that was initialize = 1 6. At last return the multiplication storing variable. C Code Snippet #include <stdio.h> int main (){ int num ; int product = 1 ; printf ( "Enter the number: " ); scanf ( " %d " , & num ); int temp = num ; while ( num != 0 ){ int digit = num % 10 ; num = num / 10 ; if ( digit % 2 == 0 ){ ...
Don't panic with coding, it will enhance your life
Comments
Post a Comment