Pages

Tuesday, 9 June 2015

C program to find largest of two positive values without using relational operator

C program to find largest of two positive values without using relational operator

Coding:

#include<stdio.h>
#include<math.h>
int main()
{
int a,b;
printf("Please enter two values:");
scanf("%d%d",&a,&b);
a=(abs(a+b)+abs(a-b))/2;
printf("Largest value is %d",a);
return 0;
}


Output:
Please enter two values:10 20
Largest value is=20