Hi,I am a new C++ learner.The follow is my program to compare the
largest and the smallest number in five numbers.However ,it always
produces wrong results.More strangely ,the largest output right,while
the smallest wrong.I don't known why
#include<stdio.h>
int main()
{
int num1,num2,num3,num4,num5;
int max=num1;
int min=num5;
printf("Enter the five numbers:\n");
scanf("%d %d %d %d %d",&num1,&num2,&num3,&num4,&num5);
if(num2>max)
max=num2;
if(num3>max)
max=num3;
if(num4>max)
max=num4;
if(num5>max)
max=num5;
printf("The largest number is %d",max);
if(num1<min)
min=num1;
if(num2<min)
min=num2;
if(num3<min)
min=num3;
if(num4<min)
min=num4;
printf("The smallest number is %d",min);
return 0;
}