C program to show the use of conditional operator

This C program show the use of conditional operator. This program find greatest among two number


// C program to show the use of conditional operator
//This C program find greatest among two numbers
//Author:Sani kamal
//date: 24-08-2017

#include<stdio.h>

int main(){
int num1,num2;
printf("Enter the value for num1 and num2:\n");
scanf("%d%d",&num1,&num2);
(num1>num2) ? printf("num1 is greatest"): printf("num2 is greatest");

&nbsp;

return 0;

}
/*
Output:
Enter the value for num1 and num2:
12
34

num2 is greatest

*/

 

Output:
Enter the value for num1 and num2:
2
4

num2 is greatest

 

 

C program to find greatest of three number

C program to reverse a given numberC program to show swap of two number without using third variables

3 thoughts on “C program to show the use of conditional operator

Leave a comment