0 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 Programming in C + – AIkiran01 804 views answer comment Share Follow Print See 1 comment 1 1 comment reply Arjun commented Jun 28, 2017 reply Follow flag Why can't you do it? 1 1 replyShare Please log in or register to add a comment.
1 1 vote #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 0 reply Please log in or register to add a comment.