C language to compare three numbers

Guanhui
Release: 2020-06-03 14:22:04
Original
38633 people have browsed it

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.

C language to compare three numbers

##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;

}
Copy after login

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!

Related labels:
c
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template