Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- comparing_4_integers_v1.c by Dragan Milicev
- You can find all my C programs at Dragan Milicev's pastebin:
- https://pastebin.com/u/dmilicev
- */
- #include <stdio.h>
- int main()
- {
- int a=1, b=2, c=3, d=4, max;
- // You can compare all this in 4 line (just for comparison)
- max = a;
- max = (b>max) ? b : max;
- max = (c>max) ? c : max;
- max = (d>max) ? d : max;
- printf("\n a = %d \t b = %d \t c = %d \t d = %d \t max = %d \n", a, b, c, d, max );
- // or,to me it is more understandable:
- max = a;
- if ( b>max ) max=b;
- if ( c>max ) max=c;
- if ( d>max ) max=d;
- printf("\n a = %d \t b = %d \t c = %d \t d = %d \t max = %d \n", a, b, c, d, max );
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment