Program to find larger of the two numbers without using if-else,while,for,switch

Answers were Sorted based on User's Feedback



Program to find larger of the two numbers without using if-else,while,for,switch..

Answer / vara

#include<stdio.h>
void main()
{
int a,b;
printf("enter a and b values");
scanf("%d%d",&a,&b);
a>b?printf("%d",a):printf("%d",b);
}

Is This Answer Correct ?    89 Yes 11 No

Program to find larger of the two numbers without using if-else,while,for,switch..

Answer / nidhish mathew

#include<stdio.h>
#include<math.h>
int main()
{
int i,j;
scanf("%d%d",&a,&b);
printf("Greater Number is %d",(a+b+abs(a-b))/2);
printf("Smallest Number is %d",(a+b-abs(a-b))/2);
}

Is This Answer Correct ?    16 Yes 8 No

Program to find larger of the two numbers without using if-else,while,for,switch..

Answer / kristian vitozev

#include <stdio.h>

int main(void)
{
int a = 7, b = 25;

a>b ? printf("%d [a]",a) : printf("%d [b]", b);

return 0;
}

Is This Answer Correct ?    9 Yes 8 No

Program to find larger of the two numbers without using if-else,while,for,switch..

Answer / vignesh1988i

#include<stdio.h>
#include<conio.h>
void main()
{
int a=90 , b=-89;
(a>b)?printf("a is larger") : printf(" b is larger ");
getch();
}

thank u

Is This Answer Correct ?    7 Yes 7 No

Program to find larger of the two numbers without using if-else,while,for,switch..

Answer / amit

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
(a>b)?printf("a is larger") : printf(" b is larger ");
getch();
}

Is This Answer Correct ?    7 Yes 7 No

Program to find larger of the two numbers without using if-else,while,for,switch..

Answer / jesica schoartzerneger

You are in wrong.

Is This Answer Correct ?    2 Yes 2 No

Program to find larger of the two numbers without using if-else,while,for,switch..

Answer / gokul prajapat

void main()
{
int a,b,max;
printf("Enter two values : ");
scanf("%d%d");
max=(a>b)*a + (a<b)*b;
printf("\nmaximum value : %d",max);
}

Is This Answer Correct ?    1 Yes 1 No

Program to find larger of the two numbers without using if-else,while,for,switch..

Answer / raj sarswat

void main()
{
int a,b;
printf("enter the value of a and b");
scanf("%d,%d",&a,&b);
a>b?printf("%d",&a):printf("%d",&b);
getch();
}

Is This Answer Correct ?    0 Yes 0 No

Program to find larger of the two numbers without using if-else,while,for,switch..

Answer / ankit chhajed

Take 3 and 150 and use code given in answer 6. We will not get the correct answer..!!!

Please give the changed code!!

Is This Answer Correct ?    0 Yes 1 No

Program to find larger of the two numbers without using if-else,while,for,switch..

Answer / guest

pls chk,wen a=3 and b=150 in code 6,it works.

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More C Interview Questions

What is the difference between ++a and a++?

0 Answers  


Can a function argument have default value?

0 Answers   Genpact,


FILE PROGRAMMING

0 Answers   Wipro,


how many header file is in C language ?

44 Answers   College School Exams Tests, CTS, IBM, IMS, Infosys, ME, Sign Solutions, Wipro, XVT,


if a is an integer variable, a=5/2; will return a value a) 2.5 b) 3 c) 2 d) 0

0 Answers  






give one ip, find out which contry

4 Answers   Google,


What is the auto keyword good for?

0 Answers  


Give me basis knowledge of c , c++...

5 Answers  


Is c is a procedural language?

0 Answers  


Is a pointer a kind of array?

0 Answers  


Write a progarm to find the length of string using switch case?

0 Answers   TCS,


Stimulate calculators to perform addition,subtraction,multiplication and division on two numbers using if/else statement?

1 Answers   IBM,


Categories