Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


how to find the largest element of array without using relational operater?

Answers were Sorted based on User's Feedback



how to find the largest element of array without using relational operater?..

Answer / upendra singh and avinash cho

#include<stdio.h>
#include<string.h>
void main()
{
int arr[4]={1,10,5,4},c,i,k,j=1;
k=arr[0];
for( i=0;i<3;i++)
{ c=k-arr[i+1];
c=c>>15;
if(c)
k=arr[i+1];
}
printf("largest number %d",k);
getch();
}

Is This Answer Correct ?    25 Yes 11 No

how to find the largest element of array without using relational operater?..

Answer / mpasinski

Regarding Answer2 - what if int in your machine is 32 bit
instead of 16. The code is not universal.

Is This Answer Correct ?    4 Yes 1 No

how to find the largest element of array without using relational operater?..

Answer / s.gayathri

using conditional operator we do that operation

Is This Answer Correct ?    3 Yes 3 No

how to find the largest element of array without using relational operater?..

Answer / hari

/*
find a largest number out of an given array without
using relational operators
*/

#include<stdio.h>
int f(int m,int n)
{if(!(m/n)) return n;

else return m;
}

int main()
{
int a[100],n=0,i,j;
scanf("%d",&n); // length of array (max 100)
for( i=0;i<n;i++)
scanf("%d",&a[i]);
int s=a[0];
a[n+1]=0;
for( j=1;j<n;j++)
{
if(f(a[j],s))
s=a[j];
}
printf("%d",s);
return 0;
}



for further queries and discussions, just check these out !!!

http://forum.campusmaniac.com/
http://www.campusmaniac.com/

Is This Answer Correct ?    1 Yes 2 No

how to find the largest element of array without using relational operater?..

Answer / dhakchina moorthy.p

sort the array first and then have the last element of the
array, which is always larger then the remaining.

Is This Answer Correct ?    0 Yes 2 No

how to find the largest element of array without using relational operater?..

Answer / bkushwaha89

code and explation.

Is This Answer Correct ?    7 Yes 14 No

Post New Answer

More C Interview Questions

If a five digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits.For example if the number that is input is 12391 then the output should be displayed as 23402

0 Answers  


what are the compilation steps? ( i want inside the compiler )

2 Answers  


What are the different types of storage classes in C?

3 Answers  


main() { char *ptr = "Ramco Systems"; (*ptr)++; printf("%s\n",ptr); ptr++; printf("%s\n",ptr); } Find the Outputs?

9 Answers   BTBP, CitiGroup,


what is object oriental programing?

1 Answers  


What is difference between Structure and Unions?

0 Answers   TISL,


prototype of sine function.

2 Answers   Cadence,


How do you write a program which produces its own source code as output?

0 Answers  


print a "hello" word without using printf n puts in c language

6 Answers  


How can I increase the allowable number of simultaneously open files?

1 Answers   CSC,


write a program to create a sparse matrix using dynamic memory allocation.

0 Answers  


what does ‘#include’ mean?

1 Answers   TCS,


Categories