Program to find greatest number between two number using ternary operator in C-language

                              Method-1
       
#include<stdio.h>
int main()
{
    int a,b,m;
    printf("Enter first number\n");
    scanf("%d",&a);
    printf("Enter second number\n");
    scanf("%d",&b);
    m=a>b?a:b;
    printf("Greatest number=%d",m);
}
                       Method-2
         
#include<stdio.h>
int main()
{
    int a,b;
    printf("Enter first number\n");
    scanf("%d",&a);
    printf("Enter second number\n");
    scanf("%d",&b);
    a>b?printf("Greatest is=%d",a):printf("Greatest is=%d",b);
}

OUTPUT
Enter first number
80
Enter second number
67
Greatest is=80

Comments

Popular posts

Creative pattern of butterfly in C-language

Program to show present time and date in C-language

Introduction of C-language.

Program to cheque enter number is a perfect number or not using if else in C-language

Program to cheque four digits number is palindrome or not in C-language

Program to print the cube of a number in c-language

Simple Hello world program in c- language