Find the remainder when First digit of a number is divided by its Last digit | C ++ program to find the remainder when the First digit of a number is divided by its Last digit ; Function to find the remainder ; Get the last digit ; Get the first digit ; Compute the remainder ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void findRemainder ( int n ) { int l = n % 10 ; while ( n >= 10 ) n /= 10 ; int f = n ; int remainder = f % l ; cout << remainder << endl ; } int main ( ) { int n = 5223 ; findRemainder ( n ) ; return 0 ; }