We can make use of an extra variable say small and when we are inputting the very first number, we can assign that first number to the small and in all other cases we can compare whether the current number is less than small, if yes then update small.
Finally outside the loop we can print the value of small and this will be our answer.
int main()
{
int t;
cin>>t;
while(t--)
{
int small;
for(int i=0;i<3;i++)
{
int n;
cin>>n;
if (i == 0)
small = n;
else {
if (n < small)
small = n;
}
}
cout<<"Smallest number is :" << small;
}
return 0;
}
input :
1
10 2 3
output :
Smallest number is :2
Flow :
At first the value 10 will be assigned as small, then for the next element 2, we compare whether 2 is less than small which is 10 in that case, and reassign small to 2. Then this small is checked with 3, but 2 < 3, so small value remains unchanged.
I assume there will be only integer values as input.
char. You can still determine the minimum of the three.