Home » Largest of 3 numbers using macros with Arguments and conditional operator.

Largest of 3 numbers using macros with Arguments and conditional operator.

#include <stdio.h>

#define LARGEST(a,b,c) (a>b?(a>c?a:c):(b>c?b:c))

void main()

{

float x=55.3, y=45.2, z=77.9,big;

int i=20, j=95, k=10,max;

clrscr();

big=LARGEST(x,y,z);

printf(“\nLargest of %8.2f %8.2f %8.2f is %8.2f”,x,y,z,big);

max=LARGEST(i,j,k);

printf(“\nLargest of %8d %8d %8d is %8d”,i,j,k,max);

getch();

}

 

OUTPUT:

2


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s