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

2. Counting in Lojban, an artificial language developed over the last fourty years, is easier than in most languages The numbers from zero to nine are: 0 no 1 pa 2 re 3 ci 4 vo 5 mk 6 xa 7 ze 8 bi 9 so Larger numbers are created by gluing the digit togather. For Examle 123 is pareci Write a program that reads in a lojban string(representing a no less than or equal to 1,000,000) and output it in numbers.

3 Answers   Nagarro,


helllo sir give me some information of the basic information the c as printf ,scanf , %d ,%f and why is the main use of these.

3 Answers  


What is key word in c language?

4 Answers   ABC,


What is queue in c?

0 Answers  


x=2,y=6,z=6 x=y==z; printf(%d",x)

13 Answers   Bharat, Cisco, HCL, TCS,


Read the following data in two different files File A: aaaaaaaadddddddd bbbbbbbbeeeeeeee ccccccccffffffff File B: 11111111 22222222 33333333 By using the above files print the following output or write it in the Other file as follows aaaaaaaa11111111dddddddd bbbbbbbb22222222eeeeeeee cccccccc33333333ffffffffffff

0 Answers  


When is a void pointer used?

0 Answers  


What is putchar() function?

0 Answers  


Write a C program to count the number of email on text

0 Answers  


1) int main() { unsigned char a = 0; do { printf("%d=%c\n",a,a); a++; }while(a!=0); return 0; } can anyone please explain the explain the output

2 Answers  


Write a program to check whether a number is prime or not using c?

0 Answers  


write the program for prime numbers?

73 Answers   Accenture, Aptech, Infosys, TCS,


Categories