/* conditional operator expr1 ? expr2 : expr3 */
#include <stdio.h>
void main()
{
int a=10,b=20,c=10,d;
d = a==b ? a : b ; /*Line-1*/
printf("The value of d in Line-1 is %d\n", d);
d = a==c ? a : b ; /*Line-2*/
printf("The value of d in Line-2 is %d\n", d);
int large = a>b ? a : b ; /* large no. checking by conditional operater */
printf("The large no. is : %d ", large);
}
output :
The value of d in Line-1 is 20
The value of d in Line-2 is 10
The large no. is : 20
No comments:
Post a Comment
smhjifrivly@gmail.com