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

main() { int i; for(i=0;i<5;i++) printf("%d",1l<<i); } why doesn't 'l' affect the code??????

1 Answers  


list the no of files created when c source file is compiled

9 Answers   TCS,


1 1 12 21 123 321 12344231 how i creat it with for loop??

1 Answers  


What is a macro in c preprocessor?

0 Answers  


What is output of the following program ? main() { i = 1; printf("%d %d %d\n",i,i++,i++); }

9 Answers   CTS, Wipro,


Where we use clrscr in c?

0 Answers  


Program to find the value of e raised to power x using while loop

5 Answers   IBM, N Tech,


#define FALSE -1 #define TRUE 1 #define NULL 0 main() { if(NULL) puts("NULL"); else if(FALSE) puts("TRUE"); else puts("FALSE"); }

1 Answers  


Is main() is used in the program,,see below example? void main() { int i; for(i=0;i<10;i++) main(); } Then what is the output of the program?

6 Answers  


what is the use of keyword volatile??

4 Answers   LG Soft,


What is the size of a union variable?

0 Answers  


Is there any restriction in how many arguments printf or scanf function can take? in which file in my c++ compiler i can see the code for implementation of these two functions??

4 Answers  


Categories