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

1)what are limitations for recursive function? 2)write a program to read a text file and count the number of characters in the text file

1 Answers  


which of the following statements is incorrect a.typedef struct new{ int n1; char n2; } DATA; b.typedef struct { int n3; char *n4; }ICE; c.typedef union { int n5; float n6; } UDT; d.#typedef union { int n7; float n8; } TUDAT;

5 Answers   Assurgent, TCS,


What is scope rule of function in c?

0 Answers  


wat is output of the following int main() { const int j=2; int i; switch(i) { case 1:break; case j:break; default:break; } }

2 Answers  


What is the general form of function in c?

0 Answers  






Is main() function predfined or userdefined?

11 Answers  


wat is the difference between a definition and declaration? float y;---it looks like a declaration..but it s a definition.how?someone explain

3 Answers   TCS,


A C E G H +B D F A I ------------ E F G H D

1 Answers   Infosys,


write a program without using main function?

2 Answers   TCS,


What are directives in c?

0 Answers  


What are the rules for the identifier?

0 Answers  


Explain how are 16- and 32-bit numbers stored?

0 Answers  


Categories