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?

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is c still so popular?

1005


Is javascript based on c?

998


The file stdio.h, what does it contain?

1116


Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

1035


Why header files are used?

1064


Write a c program to build a heap method using Pointer to function and pointer to structure ?

4622


What is your stream meaning?

1127


What is use of null pointer in c?

959


What is the explanation for cyclic nature of data types in c?

1140


What is the difference between functions abs() and fabs()?

1085


What are the disadvantages of external storage class?

1005


int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above

1222


What is the purpose of sprintf() function?

1053


When can you use a pointer with a function?

991


Compare and contrast compilers from interpreters.

1074