Write a function, smallest, which given positive integer n and a positive integer key returns the smallest digit in n greater than key. Your function should also work if there is no digit in n smaller than key.
1
Expert's answer
2018-03-24T08:03:07-0400
#include <iostream>
using namespace std;
int smallest(int n, int k) { int smallestDigit = 10;
do { int residue = n % 10;
if (residue > k && residue < smallestDigit) smallestDigit = residue; } while (n = n / 10);
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment