biggest of two no's with out using if condition statement

Answers were Sorted based on User's Feedback



biggest of two no's with out using if condition statement..

Answer / sarvanm

#include <stdio.h>
#include <math.h>
void main()
{
int m1,m2,a,b;
clrscr();
printf("Enter the First Number\n");
scanf("%d",&a);
printf("Enter the Second Number\n");
scanf("%d",&b);
m1=abs((a+b)/2);
m2=abs((a-b)/2);
printf("The Bigest No is==%d\n",m1+m2);
printf("The Smallest No is==%d\n",m1-m2);
}

Is This Answer Correct ?    15 Yes 1 No

biggest of two no's with out using if condition statement..

Answer / ansh

Use tenary operator..

c=a<b?b:a;

Is This Answer Correct ?    7 Yes 2 No

biggest of two no's with out using if condition statement..

Answer / deepshree sinha

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,m;
printf('enter any two numbers");
scanf("%d %d",&a,&b);
m=(a>b)?a:b;
printf("m=%d",m);
getch();
}

Is This Answer Correct ?    2 Yes 0 No

biggest of two no's with out using if condition statement..

Answer / ramanjaneyareddy

#include<stdio.h>
main()
{int a,b,c;
scanf("%d%d",&a,&b);
c=(a>b)?a:b;
printf("%d",c);
return(0);
}

Is This Answer Correct ?    2 Yes 3 No

biggest of two no's with out using if condition statement..

Answer / shafi.shaik

main()
{
int a,b;
a=10;
b=20;
clrscr();
if(a/b)
printf("A is Biggest");
if(b/a)
printf("B is Biggest");
getch();
}

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More C Interview Questions

What is the difference b/w main() in C language and main() in C++.

7 Answers  


how to devloped c lenguege?

4 Answers  


What are volatile variables?

1 Answers   Mind Tree,


"%u" unsigned integer print the a) address of variable b) value of variable c) name of a variable d) none of the above

0 Answers  


how to swap 2 numbers within a single statement?

4 Answers  






what are you see during placement time in the student.

0 Answers   Goldman Sachs, TCS, Tech Solutions,


1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. The Logic should be written in Data Structures?

0 Answers   KPIT,


Explain what are its uses in c programming?

0 Answers  


List the difference between a While & Do While loops?

0 Answers   Accenture,


Differentiate between #include<...> and #include '...'

0 Answers  


what are enumerations in C

0 Answers   TCS,


Write a program which take a integer from user and tell whether the given variable is squar of some number or not. eg: is this number is 1,4,9,16... or not

9 Answers   Alcatel,


Categories