I was self studying on my Arithmetic and I encounter a problem. My goal is to find the least number not the greatest. I'm quite confused.
Example output
Enter n: 42123647
Smallest digit = 7
Program
#include<stdio.h>
int main(){
int num1, num2, num3=0;
printf("Enter n: ");
scanf("%d", &num1);
while(num1>0){
num2 = num1 % 10;
if(num3<num2){
num3=num2;
}
num1 = num1 * 10;
}
printf("Smallest digit = %d",num3);
return 0;
}