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

Is sizeof a keyword in c?

0 Answers  


What are header files and what are its uses in C programming?

0 Answers  


c program to manipulate x=1!+2!+3!+...+n! using recursion

1 Answers   TCS,


What is sizeof array in c?

0 Answers  


What is the difference function call by value & function call by reference?

6 Answers  






will the program compile? int i; scanf(ā€œ%dā€,i); printf(ā€œ%dā€,i);

3 Answers  


what is data structure

5 Answers   Maveric, TCS,


Write a program to produce the following output in c language? 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1

2 Answers  


Once I have used freopen, how can I get the original stdout (or stdin) back?

0 Answers  


Why ca not I do something like this?

0 Answers  


What is wrong with this code such that it doesnt produce the input reversed? #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { char Space = ' '; char LineOfText; float count; LineOfText = getchar(); while ((LineOfText = getchar()) != '/n'); { count = strlen(LineOfText) - 1; while (count >= 0) { putchar(LineOfText[count]); count--; } } getchar(); return 0; }

2 Answers  


What does %f mean c?

1 Answers  


Categories