Skip to content
Home » Program to Find the minimum of two numbers using the conditional operator in C

Program to Find the minimum of two numbers using the conditional operator in C

Learn about Program to Find the minimum of two numbers using the conditional operator in C in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

Program to Find the minimum of two numbers using the conditional operator in C

Program:

#include<stdio.h>
int main()
{
  float num1, num2, min;
  printf("Enter two numbers: ");
  scanf("%d %d", &num1, &num2);

  //finding minimum num
  min = (num1 < num2) ? num1 : num2;
  printf("Minimum = %d", min);

  return 0;
}

Output:

Enter two numbers: 6 2
Minimum = 2

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
program to find whether the given number is odd or even using the conditional operator in C.
C program to find whether the number is positive or negative using the conditional operator.