Program to find larger of the two numbers without using if-else,while,for,switch
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
#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 |
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 |
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 |
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 |
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 |
main() { int i; for(i=0;i<5;i++) printf("%d",1l<<i); } why doesn't 'l' affect the code??????
list the no of files created when c source file is compiled
1 1 12 21 123 321 12344231 how i creat it with for loop??
What is a macro in c preprocessor?
What is output of the following program ? main() { i = 1; printf("%d %d %d\n",i,i++,i++); }
Where we use clrscr in c?
Program to find the value of e raised to power x using while loop
#define FALSE -1 #define TRUE 1 #define NULL 0 main() { if(NULL) puts("NULL"); else if(FALSE) puts("TRUE"); else puts("FALSE"); }
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?
what is the use of keyword volatile??
What is the size of a union variable?
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??