- Input a 3-digit integer.
- Print the largest digit in the integer (Tip: use % 10 to get the rightmost digit, and / 10 to remove the rightmost digit).
Input: 173
Expected Output: 7
We were given this activity 2 days old and still couldn't solve this mystery. Here's my own code which doesn't match the given expected output above:
#include<iostream>
using namespace std;
int main() {
int num, result;
cin >> num;
if(num > 0) {
result = num % 10;
num / 10;
cout << result;
}
return 0;
}