write a c program to find biggest of 3 number without
relational operator?

Answers were Sorted based on User's Feedback



write a c program to find biggest of 3 number without relational operator?..

Answer / manjeeth

void main()
{
int a = 5;
int b = 7;
int c = 2;
int res;

res = (int)(a/b)?a:b;
res = (int)(res/c)?res:c;

printf("big num = %d",res);
}

Is This Answer Correct ?    132 Yes 28 No

write a c program to find biggest of 3 number without relational operator?..

Answer / abhishek

There is small mistake in "Kishore Kumar Naik" answer.

int 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 ? nNum2 : nNum1;

nRes = nBig - nNum3;
nRes = nRes >> nSize -1;

nBig = nRes ? nNum3 : nBig;

printf("big num = %d", nBig);
}

Is This Answer Correct ?    17 Yes 16 No

write a c program to find biggest of 3 number without relational operator?..

Answer / pankaj upadhyay

using c++;
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int a,b,c;
double d;
cout<<"enter no.";
cin>>a>>b;
d=pow(2,a-b)
c=(int)d;
if(c==0)
cout<<b;
else
cout<<a;
return 0;
}

Is This Answer Correct ?    3 Yes 2 No

write a c program to find biggest of 3 number without relational operator?..

Answer / abhishek agarwal

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("a=") ;
scanf("%d",&a);
printf("b=");
scanf("%d",&b);
while (a!=0&&b!=0)
{
a=a--;
b=b--;
if (a==0)
printf ("b is greater");
if (b==0)
printf("a is greater");
}
getch();
}

For more programs see my blog cblogabhishek.blogspot.com

Is This Answer Correct ?    19 Yes 19 No

write a c program to find biggest of 3 number without relational operator?..

Answer / raheman(papi)khan

#include<stdio.h>
void main()
{
int a,b,c;
printf("enter the value of a b and c");
scanf("%d%d%d",%a,&b,&c);
int max=a;
if(b>max)
max=b;
if(c>max)
max=c;
printf("%d",max);
else
printf("equal");
}

Is This Answer Correct ?    3 Yes 3 No

write a c program to find biggest of 3 number without relational operator?..

Answer / m. priyanga

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter the values a,b,c:");
scanf("%d%d%d",&a,&b,&c);
if((a>b)&&(a>c))
printf("a is greatest of %d %d %d",a,b,c);
else if(b>c)
printf("b is greatest of %d %d %d",a,b,c);
else
printf("c is greatest of %d %d %d",a,b,c);
getch();
}
Output:
Enter the values a,b,c: 4 5 6
c is greatest of 4 5 6

Is This Answer Correct ?    2 Yes 7 No

write a c program to find biggest of 3 number without relational operator?..

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

write a c program to find biggest of 3 number without relational operator?..

Answer / keerthana

include<stdio.h>
include<conio.h>
void main()
int a,b,c;
clrscr();
printf("enter the three values:")
scanf("%d%d%d",&a,&b,&c)
if(a>b&a>c);
{
printf("a is big")
}
else
if (b>a&b>c)
{
printf("b is big")
}
else
printf("c is big");
getch();
}

Is This Answer Correct ?    6 Yes 19 No

write a c program to find biggest of 3 number without relational operator?..

Answer / zishan ahmad

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("enter the values of a,b and c");
scanf("%d%d%d",&a,&b,&c);
if(a>b && a>c)
printf("a is greatest of %d %d %d", a,b,c);
else
if(b>c)
printf("b is greatest of %d %d %d",a,b,c);
else
printf("c is gratest of %d %d %d",a,b,c);
getch();
}

Is This Answer Correct ?    1 Yes 15 No

write a c program to find biggest of 3 number without relational operator?..

Answer / rozzz

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
printf("nt Enter the first number : ");
scanf("%d",&a);
printf("nt Enter the second number : ");
scanf("%d",&b);
printf("nt Enter the third number : ");
scanf("%d",&c);
if(a>b && a>c)
printf("nt The greatest number is : %d ",a);
if(b>a && b>c)
printf("nt The greatest number is : %d ",b);
if(c>a && c>b)
printf("nt The greatest number is : %d ",c);
getch();
}

Is This Answer Correct ?    5 Yes 34 No

Post New Answer

More C Interview Questions

Explain what is the use of a semicolon (;) at the end of every program statement?

0 Answers  


the process of defining something in terms of itself is called (or) in C it is possible for the functions to call themselves. A function called a) nested function b) void function c) recursive function d) indifinite function

0 Answers  


#include<stdio.h> main() { char s1[]="Ramco"; char s2[]="Systems"; s1=s2; printf("%s",s1); } Find the output

5 Answers   CitiGroup,


To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9

0 Answers   HCL,


Why we use int main and void main?

0 Answers  






The OS is a program that uses various data structures. Like all programs in execution, you can determine the performance and other behavior of the OS by inspecting its state - the values stored in its data structures. In this part of the assignment, we study some aspects of the organization and behavior of a Linux system by observing values of kernel data structures exposed through the /proc virtual file system. The /proc virtual file system: Linux uses the /proc file system to collect information from kernel data structures. The /proc implementation provided with Linux can read many different kernel data structures. If you cd to /proc on a Linux machine, you will see a number of files and directories at that location. Files in this directory subtree each corresponds to some kernel data structure. The subdirectories with numeric names contain virtual files with information about the process whose process ID is the same as the directory name. Files in /proc can be read like ordinary ASCII files. You can open each file and read it using library routines such as fgets() or fscanf(). The proc (5) manual page explains the virtual files and their content available through the /proc file system. Requirements in detail: In this part, you are asked to write a program to report the behavior of the Linux kernel. Your program should run in two different versions. The default version should print the following values on stdout: • Processor type • Kernel version • The amount of memory configured into this computer • Amount of time since the system was last booted A second version of the program should run continuously and print lists of the following dynamic values (each value in the lists is the average over a specified interval): • The percentage of time the processor(s) spend in user mode, system mode, and the percentage of time the processor(s) are idle • The amount and percentage of available (or free) memory • The rate (number of sectors per second) of disk read/write in the system • The rate (number per second) of context switches in the kernel • The rate (number per second) of process creations in the system If your program (compiled executable) is called proc_parse, running it without any parameter should print out information required for the first version. Running it with two parameters "proc_parse <read_rate> <printout_rate>" should print out information required for the second version. read_rate represents the time interval between two consecutive reads on the /proc file system. printout_rate indicates the time interval over which the average values should be calculated. Both read_rate and printout_rate are in seconds. For instance, proc_parse 2 60 should read kernel data structures once every two seconds. It should then print out averaged kernel statistics once a minute (average of 30 samples). The second version of your program doesn't need to terminate.

0 Answers   Cognos,


What do you mean by keywords in c?

0 Answers  


What are structures and unions? State differencves between them.

0 Answers   iNautix,


WRITE A PROGRAM TO MERGE TWO SORTED ARRAY USING MERGE SORT TECHNIQUE..

0 Answers  


How can my program discover the complete pathname to the executable from which it was invoked?

0 Answers  


Write a program to reverse a string.

0 Answers   Global Logic, iNautix, TCS, Wipro,


output for following code??? main() { int x=2,y,z; x*=3+2; printf("1.%d\n",x); x*=y=z=4; printf("2.%d %d %d\n",x,y,z); x=y==z; printf("3.%d\n",x); x==(y=z); printf("%d",x); }

2 Answers   Elysium,


Categories