Q:

Find the largest of two given number using ternary condition

belongs to collection: C Programming Examples

0

Find the largest of two given number using ternary condition

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <stdio.h>
int main()
{
    int num1, num2;
    // Ask user to enter the two numbers
    printf("Please Enter Two different values\n");
    // Read two numbers from the user
    scanf("%d %d", &num1, &num2);
    (num1 >= num2)?((num1 ==num2)?printf("Both numbers are equal"):printf("%d is Largest\n", num1)):printf("%d is Largest\n", num2);
    return 0;
}

 

Output:

Please Enter Two different values 6  6
Both numbers are equal

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write C program to check whether the triangle is e... >>
<< Find the largest of two numbers using the if-else ...