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

What is static volatile in c?

1075


What is the difference between text and binary modes?

1239


How can I use a preprocessorif expression to ?

1110


What is the Purpose of 'extern' keyword in a function declaration?

1140


What is 1d array in c?

1156


will u please send me the placement papers to my mail???????????????????

1883


What extern c means?

1060


my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?

1644


Hello. How to write a C program to check and display president party like if i type in the console "biden" and hit enter the output shoud be : "biden is democrat" and if i type "trump" and hit enter the output shoud be: "trump is republican"

2121


What does %p mean?

1154


What is a pointer on a pointer in c programming language?

1186


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

1260


how can use subset in c program and give more example

2046


What is integer constants?

1131


I have written a pro*C program to fetch data from the cursor. where in i have used the concept of BULK FETCH.... each FETCH statement is taking lots of time to fetch specified number of rows at...

10244