You can do

#define new_max(x,y) (((x) >= (y)) ? (x) : (y))
#define new_min(x,y) (((x) <= (y)) ? (x) : (y))

valter

Answer from γηράσκω δ' αεί πολλά διδασκόμε on Stack Overflow
🌐
w3resource
w3resource.com › c-programming-exercises › pointer › c-pointer-exercise-6.php
C Program: Find the maximum number between two numbers - w3resource
#include <stdio.h> #include <stdlib.h> int main() { int fno, sno, *ptr1 = &fno, *ptr2 = &sno; printf("\n\n Pointer : Find the maximum number between two numbers :\n"); printf("------------------------------------------------------------\n"); printf(" Input the first number : "); scanf("%d", ptr1); // Read the first number from the user and store it using ptr1 printf(" Input the second number : "); scanf("%d", ptr2); // Read the second number from the user and store it using ptr2 // Compare the values pointed by ptr1 and ptr2 to find the maximum number if (*ptr1 > *ptr2) { printf("\n\n %d is the maximum number.\n\n", *ptr1); // Print the maximum number } else { printf("\n\n %d is the maximum number.\n\n", *ptr2); // Print the maximum number } return 0; }
🌐
Techcrashcourse
techcrashcourse.com › 2015 › 11 › c-program-maximum-two-numbers-ternary-operator.html
C Program to Find Maximum of Two Numbers
We will first take two numbers as input from user using scanf function. Then we print the maximum number on screen. ... The algorithm begins by taking two numbers, num1 and num2, as input. It then compares the two numbers using an if statement. If num1 is greater than num2, it assigns the value of num1 to the variable max.
🌐
Allbca
dreamstudy.allbca.com › c19.html
'C' Larger of 2 num.(by Function)
//Find Larger of two num. using Function #include<stdio.h> #include<conio.h> int max(int a,int b); main() { int x,y; printf("Enter any two number:"); scanf("%d%d",&x,&y); max(x,y); } int max(int a,int b) { if(a>b) printf("A is greater"); else printf("B is greater"); getch(); } ... Here,we will ...
🌐
IncludeHelp
includehelp.com › code-snippets › c-program-to-define-macro-to-find-maximum-of-two-numbers.aspx
C program to define Macro to find maximum of two numbers - IncludeHelp
The code segment ((x>y)?x:y) will be replaced as ((a>b)?a:b) (a and b are the actual arguments in the below written program) instead of Macro calling MAX(a,b). ... #include <stdio.h> #define MAX(x,y) ((x>y)?x:y) int main() { int a,b,max; printf("Enter first number: "); scanf("%d",&a); printf("Enter second number: "); scanf("%d",&b); max=MAX(a,b); printf("Maximum number is: %d\n",max); return 0; }
🌐
Codeforwin
codeforwin.org › home › c program to find maximum between two numbers
C program to find maximum between two numbers - Codeforwin
July 20, 2025 - We can write expression to find maximum between num1 and num2 as num1 > num2. The expression num1 > num2 evaluate 1 if num1 is greater than num2, otherwise evaluates 0. After finding maximum, we need to execute some action based on the maximum i.e.
🌐
PREP INSTA
prepinsta.com › home › c program › find the greatest of the two numbers in c
C Program to Find Greatest of Two Numbers | Prepinsta
March 19, 2025 - ... #include<stdio.h> int main ... is greater", num2); return 0; } ... In this method, we’ll use the knowledge of Ternary Operator in C ....
🌐
w3resource
w3resource.com › c-programming-exercises › c-snippets › c-program-to-define-macro-to-find-maximum-minimum-of-two-numbers.php
C – Macro to find maximum/minimum of two numbers
# include <stdio.h> #define MAX(x, y) ((x) > (y) ? (x) : (y)) #define MIN(x, y) ((x) < (y) ? (x) : (y)) int main() { int a = 45, b = 34; printf("The Maximum of %d and %d is %d\n", a, b, MAX(a, b)); printf("The Minimum of %d and %d is %d\n", a, b, MIN(a, b)); return 0; } ... In the above code, the MAX and MIN macros are defined using the ternary operator to check which of the two numbers is larger or smaller.
Find elsewhere
🌐
myCompiler
mycompiler.io › view › CiMQGT0n5Uh
Write a C program to find maximum between two numbers using conditional operator (C) - myCompiler
Copy link Download Share on Facebook Share on Twitter Share on Reddit Embed on website · #include <stdio.h> int a,b; int main() { scanf("%d %d ",&a,&b); if(a>b){ printf("a is grater of two number"); } else{ printf("b is grater of two number"); } return 0; } Output ·
🌐
CodeCrucks
codecrucks.com › home › programs › c program to find maximum of two numbers
C Program to Find Maximum of Two Numbers - CodeCrucks
March 21, 2023 - //WAP to find the maximum of the 2 numbers #include <stdio.h> int main() { int n1, n2; printf("Enter the number 1 :--> "); scanf("%d", &n1); printf("Enter the number 2 :--> "); scanf("%d", &n2); if(n1 > n2) { printf("\nThe largest number among %d and %d is %d", n1, n2, n1); } else { printf("\nThe largest number among %d and %d is %d", n1, n2, n2); } return 0; }
🌐
Quora
quora.com › What-is-a-C-program-to-find-the-maximum-number-between-two-numbers
What is a C program to find the maximum number between two numbers? - Quora
Answer (1 of 12): So you have two numbers a and b, and you would like the number x which is “between” a and b, and which is the largest such number. What does “between” mean? If we suppose a
🌐
Aticleworld
aticleworld.com › home › c program to find largest of two given numbers
C program to find largest of two given numbers - Aticleworld
December 25, 2023 - Read the two integer values in num1 and num2 (integer variables). Check if num1 is greater than num2. If true, then print ‘num1’ as the greatest number. If false, then print ‘num2’ as the greatest number. Using if-else Statement. Using ternary operator. Using macros. Using Bit-wise Operator. Let’s discuss each of ...
🌐
Learn Java
javatutoring.com › c-program-find-maximum-between-two-numbers
C Program Find Maximum Between Two Numbers | C Programs
November 26, 2025 - Suitable examples and sample programs have also been added so that you can understand the whole thing very clearly. The compiler has also been added with which you can execute it yourself. ... As we are discussing in this blog, a maximum number between two numbers is decided based on their absolute value.
🌐
myCompiler
mycompiler.io › view › 68tvfxkuRh2
c program to find greatest of two numbers (C) - myCompiler
Copy link Download Share on Facebook Share on Twitter Share on Reddit Embed on website · #include <stdio.h> int main() { int x,y; printf("Enter the two numbers \n"); scanf("%d%d",&x,&y); if(x>y) { printf("x is greater than y\n"); }else { printf("y is greater than x\n"); } } Output ·
🌐
w3resource
w3resource.com › c-programming-exercises › inline_function › c-inline-function-exercise-4.php
C inline function - Compute the maximum of two integers
#include <stdio.h> inline int max(int ... 0; } ... In the above program, we define an inline function max() that takes two integers x and y as parameters and returns the maximum value between them....
🌐
ProCoding
procoding.org › c-program-to-find-maximum-between-two-numbers
C Program to find maximum between two numbers | ProCoding
April 23, 2020 - Write a C Program to find the maximum between two numbers using if-else conditional statement. #include <stdio.h> void main() { int num1, num2; printf("Enter first number: "); scanf("%d", &num1); printf("Enter second number: "); scanf("%d", ...
🌐
GeeksforGeeks
geeksforgeeks.org › dsa › compute-maximum-of-two-integers-in-c-c-using-bitwise-operators
Compute maximum of two integers in C/C++ using Bitwise Operators - GeeksforGeeks
July 23, 2025 - // C program for the above approach ... = a - b; // Right shift and Bitwise AND i = (z >> 31) & 1; // Find the maximum number max = a - (i * z); // Return the maximum value return max; } // Driver Code int main() { int A = 40, B = ...
🌐
Tutorial Gateway
tutorialgateway.org › c-program-to-find-largest-of-two-numbers
C Program to Find Largest of Two Numbers
October 13, 2017 - Within this C Program to Find the Largest of Two Numbers example, First, We declared three integer variables called a, b, and largest.
🌐
Brainly
brainly.in › english › secondary school
Write a C program to find maximum of two numbers using conditional operator ?#include #include void main(){ - Brainly.in
December 26, 2022 - /* Take two numbers as input from user · using scanf function */ printf("Enter Two Integers\n"); scanf("%d %d", &a, &b); if(a == b){ printf("Both Equal\n"); return 0; } /* Finds maximum using Ternary Operator */ maximum = (a > b) ? a : b; printf("%d is Maximum\n", maximum); return 0; } Advertisement · Advertisement · Describe the characteristics of Buddhist system of India ·