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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why c is faster than c++?

629


What is the role of this pointer?

547


What is extern variable in c with example?

538


In C programming, what command or code can be used to determine if a number of odd or even?

621


How to write c functions that modify head pointer of a linked list?

543






Program will then find the largest of three numbers using nested if-else statements. User is prompted to enter three numbers. Program will find the largest number and display it on the screen. All three numbers entered by the user are also displayed. If user enters 21, 33, and 5, the output should be as follows: You entered: 21, 33 and 5. The largest number is 33.

1014


How can I insert or delete a line (or record) in the middle of a file?

574


What is the use of the function in c?

596


the factorial of non-negative integer n is written n! and is defined as follows: n!=n*(n-1)*(n-2)........1(for values of n greater than or equal to 1 and n!=1(for n=0) Perform the following 1.write a c program that reads a non-negative integer and computes and prints its factorial. 2. write a C program that estimates the value of the mathematical constant e by using the formula: e=1+1/!+1/2!+1/3!+.... 3. write a c program the computes the value ex by using the formula ex=1+x/1!+xsquare/2!+xcube/3!+....

22212


What is the use of sizeof?

554


What is the difference between functions abs() and fabs()?

647


How do c compilers work?

608


What is keyword in c?

602


What is the difference between fread and fwrite function?

639


What is the use of #define preprocessor in c?

615