Home  >  Article  >  Backend Development  >  How to input two numbers in C language and output the largest number?

How to input two numbers in C language and output the largest number?

coldplay.xixi
coldplay.xixiOriginal
2020-06-22 16:40:3634401browse

How to input two numbers in C language and output the largest number?

Recommended tutorial: "c Video Tutorial"

How to input two numbers in C language and output the largest number?

C language inputs two numbers and outputs the maximum number method: first define two numbers a and b; then make a judgment. If [a>b], the maximum value is a and output a; finally If [a

Example:

#include<stdio.h>
int main(void)
{
int a,b;
printf("请两个输入数值,中间用空格隔开:");
scanf("%d%d",&a,&b);
if(a>b) {printf("最大值为%d\n",a);}
else {printf("最大值为%d\n",b);}
}

Recommended related articles: "c#.net development graphic tutorial"

The above is the detailed content of How to input two numbers in C language and output the largest number?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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