Home > Article > Backend Development > C language to compare three numbers
C language compares the size of three numbers
First compare the size of the first number and the second number. If the first number If the number is greater than the second number, the first number and the second number will be interchanged. If not greater, no processing will be done; then the second number and the third number will be compared. Similarly, if they are greater than the second number, they will be interchanged; finally After comparison, the last number is the largest.
##Code
#include<stdio.h> //#include<windows.h> void main() { int max3(int a,int b,int c); int a,b,c,result; printf("Pleaseenterthreenumber:\n"); scanf("%d,%d,%d",&a,&b,&c); result=max3(a,b,c); printf("Themaxofthreenumberis%d:\n",result); //system("pause"); } int max3(int a,int b,int c) { int x,z; if(a>b) x=a; else x=b; if(x>c) z=x; else z=c; return z; }Recommended tutorial: "
C#"
The above is the detailed content of C language to compare three numbers. For more information, please follow other related articles on the PHP Chinese website!