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

Explain the difference between structs and unions in c?

0 Answers  


When should I declare a function?

0 Answers  


find the size of structure without using the size of function

1 Answers   Bosch,


Write a client and server program in C language using UDP, where client program interact with the Server as given below: i) The client begins by sending a request to send a string of 8 characters or series of 7 numbers, the server sends back a characters or numbers as per the request of the client. ii) In case of series of 7 numbers: The client sends a multiplication of numbers, to the server. iii) In case of a string of 8 characters: The client sends a reverse order of string to the server.. iv) Server will send an acknowledgment to the client after receiving the correct answer

0 Answers   Ignou, Microsoft,


What is the right way to use errno?

0 Answers  






Write a program to find the given number is odd or even without using any loops(if,for,do,while)

4 Answers   CNC, Gokul,


How can a process change an environment variable in its caller?

0 Answers  


Write a simple program to find the size of different basic data types in C.

3 Answers  


How can I increase the allowable number of simultaneously open files?

1 Answers   CSC,


1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. The Logic should be written in Data Structures?

0 Answers   KPIT,


void main() { int s[4][2]={ {1234,56},{1212,33},{1434,80},{1312,78} }; int (*p)[2]; int i,j,*pint; for(i=0;i<=3;i++) { p=&s[i]; pint=p; printf("\n"); for(j=0;j<=1;j++) printf("%d",*(pint+j)); } } while running this program it shows a warning-suspicious pointer conversion ie pint=p; my que is why should we assign the value of p to pint again.why cant we use it directly as *(p+j)..but if i use like tat the o/p is garbage value..

1 Answers  


What is a sequential access file?

0 Answers  


Categories