Skip to content
Home » C program to enter two numbers Make a comparison between them with the conditional operator

C program to enter two numbers Make a comparison between them with the conditional operator

Learn about program to enter two numbers. Make a comparison between them with 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.

C program to enter two numbers. Make a comparison between them with the conditional operator

Source code:

#include<stdio.h>
int main()
{
  float a,b,result;
  printf("Enter two number: ");
  scanf("%f %f", &a, &b);

  result = (a>b)? a/b : a*b;
  printf("Result: %.1f",result);

  return 0;
}

Output:

Enter two number: 4 8
Result: 32.0

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 the minimum of two numbers using the conditional operator in C
program to find whether the given number is odd or even using the conditional operator in C.