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

how to write a cprogram yo get output in the form * *** ***** ******* ********* ******* ***** *** *

3 Answers  


What is the value of uninitialized variable in c?

0 Answers  


Explain what does the function toupper() do?

0 Answers  


where does malloc() function get the memory?

1 Answers  


What is echo in c programming?

0 Answers  






Who had beaten up hooligan "CHAKULI" in his early college days?

1 Answers  


what is the difference between. system call and library function?

2 Answers   CDAC, Satyam,


wt is d full form of c

6 Answers   TCS, Wipro,


write a c program to find the roots of a quadratic equation ax2 + bx + c = 0

11 Answers   CSC, St Marys, TATA,


what is the difference between declaration ,defenetion and initialization of a variable?

7 Answers   LG Soft,


Find string palindrome 10marks

5 Answers   Honeywell, Infosys, Riktam, Roland,


Find Error if any in below code, Justify ur answer: struct xx { int a; struct yy { char c; struct xx* p; } struct yy* q; }

3 Answers   NDS,


Categories