by CodeChum Admin
This one is a bit tricky. You're going to have to isolate each digit of the integer to determine which one is the largest, so good luck!
Instructions:
Input
1. A three-digit integer
Output
The first line will contain a message prompt to input the 3-digit integer.
The last line contains the largest digit of the inputted integer.
Enter·a·3-digit·integer:·173
Largest·=·7
#include <stdio.h>
int main() {
int x;
int d, m;
printf("Enter a 3 digit integer: ");
scanf("%d", &x);
m = x%10;
x /= 10;
d = x%10;
x /= 10;
if (d > m) m = d;
if (x > m) m = d;
printf("Lagest = %d\n", m);
return 0;
}
Comments
Leave a comment