0 votes 0 votes Write a program which will find the sum of product of consecutive digits . Eg When the input is 23145 the output is 2×3+3×1+1×4+4×5 = 33 AIkiran01 asked Jun 28, 2017 AIkiran01 479 views answer comment Share Follow See 1 comment See all 1 1 comment reply Arjun commented Jun 28, 2017 reply Follow Share Why can't you do it? 1 votes 1 votes Please log in or register to add a comment.
1 votes 1 votes #include<stdio.h> int cProduct(int); int main(){ printf("%d\n", cProduct(123456)); } int cProduct(int num){ if(num<10) return num; int result = 0; while(num){ /* Making use of the fact that multiplication and addition are commutative */ result += num%10*((num%100)/10); num/=10; } return result; } Sudha S answered Jul 4, 2017 Sudha S comment Share Follow See all 0 reply Please log in or register to add a comment.