write a c program for greatest of three numbers without
using if statment

Answers were Sorted based on User's Feedback



write a c program for greatest of three numbers without using if statment..

Answer / sathishmani

void main()
{
int a=10,b=20,c=30,d;
d=((a>b)&&(a>c))?1:2;
switch(d)
{
case 1:
printf("%d",a);
break;
case 2:
d=(b>c)?b:c;
printf("%d",d);
break;
}
}

Is This Answer Correct ?    68 Yes 21 No

write a c program for greatest of three numbers without using if statment..

Answer / swathi

main()
{
int a,b,c,s1,big;
printf("enter 3 values");
scanf("%d %d %d", &a,&b,&c);
s1=(a>b)? a : b;
big= (s1>c)? s1 : c;
printf("largest of 3 no's=%d",big);
}

Is This Answer Correct ?    23 Yes 6 No

write a c program for greatest of three numbers without using if statment..

Answer / ragu

int call();
void main()
{
int a,b,c,d;
printf("enter the values");
scanf("%d%d%d",&a,&b,&c);
d=call();
}
call()
{
return(a>b?a>c?a:c:b>c?b:c);
}

Is This Answer Correct ?    28 Yes 19 No

write a c program for greatest of three numbers without using if statment..

Answer / suresh

main()
{
int a,b,c,big;
printf("enter 3 values");
scanf("%d %d %d", &a,&b,&c);
big= ((a>b)&&(a>c))? a :b>c?b:c;
printf("largest of 3 no's = %d",big);
}

Is This Answer Correct ?    6 Yes 2 No

Post New Answer

More C Interview Questions

nic scientist exam

1 Answers   NIC,


what would be the output of the following prog? Justify your answer? main() { unsigned char ch; unsigned char i; ch = -255; printf("%d",ch); i = -1; printf("%d",i); }

1 Answers  


how to set Nth bit of variable by using MACRO

3 Answers   HCL,


int a=0,b=2; if (a=0) b=0; else b=*10; What is the value of b ?

6 Answers   TCS,


What happens if a header file is included twice?

0 Answers  






Please write the area of a RIGHT ANGLED TRIANGLE.

1 Answers  


List a few unconditional control statement in c.

0 Answers  


What is the scope of static variables?

1 Answers  


what does keyword ‘extern’ mean in a function declaration?

1 Answers   Emerson,


how to add our own function in c library please give details.?

1 Answers   TCS,


What are keywords in c with examples?

0 Answers  


Where are some collections of useful code fragments and examples?

0 Answers   Celstream,


Categories