write a c program to find biggest of 3 number without
relational operator?
Answer Posted / kishore kumar naik p
All above answers are wrong.
For "Manjeeth" answer, it does not work always, for example
a= -8, b = 2;
then
res = (int)(a/b)?a:b;
statement says a as big
res = (int)(-8/2)?-8:2;
res = in(-4)?-8:2
res = -8;
which is wrong.
The other two answers are using relational operators so it
does not answer the question. And finally the answer is
void main()
{
int nNum1, nNum2, nNum3;
int nRes,nSize, nBig;
nSize = sizeof(int) * 8;
printf("\nEnter 3 numbers");
scanf("%d%d%d", &nNum1, &nNum2, &nNum3);
nRes = nNum1 - nNum2;
nRes = nRes >> nSize -1;
nBig = nRes ? nNum1 : nNum2;
nRes = nBig - nNum3;
nRes = nRes >> nSize -1;
nBig = nRes ? nBig : nNum3;
printf("big num = %d", nBig);
}
| Is This Answer Correct ? | 18 Yes | 26 No |
Post New Answer View All Answers
What are the different types of control structures in programming?
Write a program to reverse a linked list in c.
Explain what is operator promotion?
What's the total generic pointer type?
Write a program to maintain student’s record. Record should
not be available to any unauthorized user. There are three
(3) categories of users. Each user has its own type. It
depends upon user’s type that which kind of operations user
can perform. Their types and options are mentioned below:
1. Admin
(Search Record [by Reg. No or Name], View All Records,
Insert New Record, Modify Existing Record)
2. Super Admin
(Search Record [by Reg. No or Name], View All Records,
Insert New Record, Modify Existing Record, Delete Single Record)
3. Guest
(Search Record [by Reg. No or Name], View All Records)
When first time program runs, it asks to create accounts.
Each user type has only 1 account (which means that there
can be maximum 3 accounts). In account creation, following
options are required:
Login Name: <6-10 alphabets long, should be unique>
Password: <6-10 alphabets long, should not display
characters when user type>
Confirm Password:
main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }
What are the advantages of using macro in c language?
What is #ifdef ? What is its application?
What are comments and how do you insert it in a C program?
What is .obj file in c?
1.int a=10; 2.int b=20; 3. //write here 4.b=30; Write code at line 3 so that when the value of b is changed variable a should automatically change with same value as b. 5.
Can we access the array using a pointer in c language?
what are the facialities provided by you after the selection of the student.
In this problem you are to write a program that will cut some number of prime numbers from the list of prime numbers between 1 and N.Your program will read in a number N; determine the list of prime numbers between 1 and N; and print the C*2 prime numbers from the center of the list if there are an even number of prime numbers or (C*2)-1 prime numbers from the center of the list if there are an odd number of prime numbers in the list.
how to create duplicate link list using C???