Also view this program using -
C program to find maximum between two numbers using if else.
C program to find maximum between two numbers using switch case.
C program to find maximum or minimum between two numbers using functions.
Example:
Input first number: 10
Input second number: 20
Output maximum: 20
Required knowledge
Basic C programming, Conditional operatorProgram to find maximum using conditional operator
/** * C program to find maximum between two numbers using conditional operator */ #include <stdio.h> int main() { int num1, num2, max; /* * Reads two number from user */ printf("Enter two numbers: "); scanf("%d %d", &num1, &num2); /* Finds maximum using conditional operator */ max = (num1>num2) ? num1 : num2; printf("Maximum between %d and %d is %d", num1, num2, max); return 0; }
Output
Enter two numbers: 10
20
Maximum between 10 and 20 is 20
20
Maximum between 10 and 20 is 20
Happy coding ;)
You may also like
- C program to find maximum between three numbers using conditional operator.
- C program to check whether a number is even or odd using conditional operator.
- C program to check whether a character is alphabet or not using conditional operator.
- C program to find maximum between three numbers.
- C program to check whether a triangle is Equilateral, Isosceles or Scalene triangle.
- C program to print table of any number.
- C program to enter any number and print it in words.
- C program to calculate sum of digits of any number.
- C program to check whether a number is palindrome or not.
- C program to find all factors of any number.