Sunday, July 12, 2009

Write a program in c to find the biggest of 3 numbers using conditional operator?

If you are able to use conditional operator*s*:


And if efficiency doesn't matter at all.


And assuming you are comparing ints





int x, y, z; give them values....


int high_number;


if(x %26gt;= y %26amp;%26amp; x %26gt;= z)


high_number = x;


else if(y %26gt;= x %26amp;%26amp; y %26gt;= z)


high_number = y;


else


high_number = z;

Write a program in c to find the biggest of 3 numbers using conditional operator?
#include %26lt;stdio.h%26gt;





#include %26lt;conio.h%26gt;





void main()


{


int one, two,three,big;





scanf("%d%d%d",%26amp;one,%26amp;two,%26amp;three);





big=one%26gt;two?(one%26gt;three?one:three) :(two%26gt;three?two:three);





printf("big %d",big);





getch();


}
Reply:int biggest(int a , int b , int c)


{


return a%26gt;b?a%26gt;c?a:c:b%26gt;c?b:c;


}


No comments:

Post a Comment