


C language program to find the maximum value among 3 numbers
1. Write a C language program that can input 3 numbers and find the largest number among them.
#include <stdio.h> int main() { int num1, num2, num3; // 输入三个数 printf("请输入三个整数,用空格分隔:"); scanf("%d %d %d", &num1, &num2, &num3); // 找出最大值 int max = num1; if (num2 > max) { max = num2; } if (num3 > max) { max = num3; } // 输出最大值 printf("最大值是:%d\n", max); return 0; }
2. Use C language to design the algorithm for the largest number among three numbers
#include <stdio.h> int findMax(int a, int b, int c) { int max = a; if (b > max) { max = b; } if (c > max) { max = c; } return max; } int main() { int num1, num2, num3; // 输入三个数 printf("请输入三个整数,用空格分隔:"); scanf("%d %d %d", &num1, &num2, &num3); // 调用函数找出最大值 int max = findMax(num1, num2, num3); // 输出最大值 printf("最大值是:%d\n", max); return 0; }
3. Beginners: How to output three numbers in C language The largest number among the numbers
#include <stdio.h> int main() { int num1, num2, num3; // 输入三个数 printf("请输入三个整数,用空格分隔:"); scanf("%d %d %d", &num1, &num2, &num3); // 找出最大值 int max = num1; if (num2 > max) { max = num2; } if (num3 > max) { max = num3; } // 输出最大值 printf("最大值是:%d\n", max); return 0; }
4. C language inputs three numbers and outputs the maximum and minimum values
#include <stdio.h> int main() { int num1, num2, num3; // 输入三个数 printf("请输入三个整数,用空格分隔:"); scanf("%d %d %d", &num1, &num2, &num3); // 找出最大值 int max = num1; if (num2 > max) { max = num2; } if (num3 > max) { max = num3; } // 找出最小值 int min = num1; if (num2 < min) { min = num2; } if (num3 < min) { min = num3; } // 输出最大与最小值 printf("最大值是:%d\n", max); printf("最小值是:%d\n", min); return 0; }
Summary
- (1) C language can find the maximum and minimum values among multiple input numbers through conditional statements (if statements).
- (2) Using functions to encapsulate algorithms is a good programming practice and helps code reuse and maintenance.
- (3) The input and output functions
scanf
andprintf
are used for input and output on the console.
The above is the detailed content of C language program to find the maximum value among 3 numbers. For more information, please follow other related articles on the PHP Chinese website!

If you want to buy a top printer & scanner, this post lists some best printers and scanners and copiers including some top HP printers and scanners. php.cn Software not only provides useful computer software but also provides various computer tut

You can use the built-in Network Adapter troubleshooter in Windows 11 to find and fix problems with wireless and other network adapters. This post teaches you how to find and run Windows 11 network adapter troubleshooter with detailed instructions. S
![[Solved] Battlefield 2042 Black Screen Issues (7 Solutions) - MiniTool](https://img.php.cn/upload/article/001/242/473/174698221230413.png?x-oss-process=image/resize,p_40)
Battlefield 2042 black screen then crash is an annoying problem when gaming. How to fix it? This guide on php.cn Website aims at tackling this issue. Look it through carefully and we sincerely hope that our solutions will work fine for you.

Have you ever encountered Dev Error 11557 in Call of Duty: Modern Warfare 2 or Warzone 2? If you are, you come to the right place. In this post, php.cn provides some potential solutions to help you fix this error.

If you want to cancel your Apple Music subscription, there are several ways to do so. This post from php.cn tells you how to cancel your subscription using your iPhone, iPad, Android device, Mac, or the Apple TV.

Microsoft 365 offers several subscription plans for you to choose from. This post introduces and compares all Microsoft 365 plans. You can choose a preferred Microsoft 365 plan based on your own needs. To recover deleted or lost files like Office fil

The VLC media player is a free and open-source, portable, cross-platform media player software and streaming media server, which is available for desktop operating systems and mobile platforms. But some people find the “VLC not playing videos” issue

To manage your daily tasks, you can use the free task management app - Microsoft To Do. This post teaches you how to download Microsoft To Do on Windows 10/11, Mac, iPhone/iPad, or Android. If you are looking for more computer tips and solutions, you


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
