Home >Backend Development >C#.Net Tutorial >How to input 3 numbers in C language and output the maximum value
Method: First use scanf() to receive three numbers input from the keyboard; then use the "if else" statement to compare the sizes of the three numbers to obtain the maximum value; finally use the print() function to output the maximum value That’s it.
The operating environment of this tutorial: windows7 system, c99 version, Dell G3 computer.
c language input 3 numbers and output the maximum value
#include <stdio.h> int main() { // 输入abc输出最大值 int a; int b; int c; int max; scanf("%d %d %d", &a, &b, &c); // 输入请空格隔开最后回车 /* if (a > b) { max = a; } else { max = b; } */ max = a; if (b > max) { max = b; } if (c > max) { max = c; } printf("%d\n", max); return 0; }
Run:
Related recommendations:《C language video tutorial》
The above is the detailed content of How to input 3 numbers in C language and output the maximum value. For more information, please follow other related articles on the PHP Chinese website!